J
John
Hi there,
I'm fairly new to VB.Net (and VB generally) so please bear with me if these
are stupid questions!
I'm trying run a procedure on multiple Visio files from a form created in VS
2003. This has worked fine when run from a click event on a single form at
the start. It selected the items in a listbox (lstWorkFiles) and then went
through each one. Now however, I moved the code to a second form (fmOps),
which has some check boxes, and is run from a click event on btProcess and
I'm getting a "Object reference not set to an instance of an object" error
from the exception handler. So my questions are:
a) Is there a way to add a value to the exception message showing the line
number that threw the exception?
b) Can anyone see what I'm doing wrong in the code below to produce this
error? (I'm assuming the problem is that I'm not referencing the Form1 in
the right way?)
c) When you step through code with F8 the respective line is highlighted
yellow, but when a form is showing this seems to disappear. Is there a way
around this?
Many thanks in advance
John
Public Sub btProcess_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btProcess.Click
Dim openingForm As Form1
Try
Dim vDoc As Document 'Visio Document
Dim vWin As Window 'Visio Window
m_appVisio = GetObject(, "visio.application")
Dim itm As ListViewItem
For Each itm In openingForm.lstWrkFiles.Items
vDoc = m_appVisio.Documents.Open(itm.Text)
'Whole Page View
If ckBxWholePageView.Checked = True Then
AllPageWholeView(vDoc)
End If
System.Windows.Forms.MessageBox.Show("Done", MessageBoxButtons.OK)
vDoc.Close()
Next
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub
I'm fairly new to VB.Net (and VB generally) so please bear with me if these
are stupid questions!
I'm trying run a procedure on multiple Visio files from a form created in VS
2003. This has worked fine when run from a click event on a single form at
the start. It selected the items in a listbox (lstWorkFiles) and then went
through each one. Now however, I moved the code to a second form (fmOps),
which has some check boxes, and is run from a click event on btProcess and
I'm getting a "Object reference not set to an instance of an object" error
from the exception handler. So my questions are:
a) Is there a way to add a value to the exception message showing the line
number that threw the exception?
b) Can anyone see what I'm doing wrong in the code below to produce this
error? (I'm assuming the problem is that I'm not referencing the Form1 in
the right way?)
c) When you step through code with F8 the respective line is highlighted
yellow, but when a form is showing this seems to disappear. Is there a way
around this?
Many thanks in advance
John
Public Sub btProcess_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btProcess.Click
Dim openingForm As Form1
Try
Dim vDoc As Document 'Visio Document
Dim vWin As Window 'Visio Window
m_appVisio = GetObject(, "visio.application")
Dim itm As ListViewItem
For Each itm In openingForm.lstWrkFiles.Items
vDoc = m_appVisio.Documents.Open(itm.Text)
'Whole Page View
If ckBxWholePageView.Checked = True Then
AllPageWholeView(vDoc)
End If
System.Windows.Forms.MessageBox.Show("Done", MessageBoxButtons.OK)
vDoc.Close()
Next
Catch ex As Exception
System.Windows.Forms.MessageBox.Show(ex.Message)
End Try
End Sub