3 Replies Latest reply on Jul 28, 2010 4:23 AM by Andreas.Schaefer

    Automation template problem




      I have this code and I get a error if I want to know the procject.pcb name

      Any idea?


      Public Class FrmGrassValleyOutput
          Dim ProjectName As String
          Dim PrjPath As String
          Dim Gencadfile As String = "Gencad.cad"
          Public app As MGCPCB.ExpeditionPCBApplication
          Public Doc As MGCPCB.Document

          Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing

          End Sub

          Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
                  End Sub

          Private Sub MainForm_FormClosed(ByVal sender As System.Object, ByVal e As System.Windows.Forms.FormClosedEventArgs) Handles MyBase.FormClosed
          End Sub
          Private Sub btnFulloutput_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnFulloutput.Click
              ProjectName = Projectfile(Doc)
           End Sub

          Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
          End Sub

          Public Function Projectfile(ByVal doc)
              Dim sTmp, sTemp As String
              Dim StartPos, CharCount, MyLen, StrPos As Integer
              sTmp = doc.FullName    <======================I get here a error : NULLreferenceException was unhandled
              StrPos = InStr(sTmp, "\PCB\")
              '    MsgBox(StrPos)
              '    MsgBox(sTmp)
              MyLen = Len(sTmp)
              If MyLen = 43 Then
                  StartPos = StrPos + 5
                  CharCount = 9
                  sTemp = Mid(sTmp, StartPos, CharCount)
                  Projectfile = sTemp
                  '     MsgBox(sTemp)
                  Projectfile = "Projectfile not found"
              End If
          End Function
      End Class