Public Class ThisAddIn
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs ) _
Handles Me.Startup
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Shutdown
End Sub
End Class
1. Import Visio Interoperability reference before the class definition and define a variable, vsoDoc for Visio document.
Imports Microsoft.Office.Interop.Visio
Public Class ThisAddIn
Private vsoDoc As Visio.Document
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs ) _
Handles Me.Startup
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Shutdown
End Sub
2. Add codes of Visio document creation in ThisAddIn_Startup()
Imports Microsoft.Office.Interop.Visio
Public Class ThisAddIn
Private vsoDoc As Visio.Document
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs ) _
Handles Me.Startup
vsoDoc = Application.Documents.Add("")
vsoDoc = Application.Documents.OpenEx("Basic Shapes.vss", _
visOpenDocked + visOpenCopy)
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Shutdown
End Sub
3. To resolve errors with the flags visOpenDocked and visOpenCopy, append VisOpenSaveArgs to each flag. If VisOpenSaveArgs is not used, Visual Studio shows errors such as "Name 'visOpenDocked' is not declared."
Public Class ThisAddIn
Private vsoDoc As Visio.Document
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs ) _
Handles Me.Startup
vsoDoc = Application.Documents.Add("")
vsoDoc = Application.Documents.OpenEx("Basic Shapes.vss", _
visOpenDocked + visOpenCopy)
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Shutdown
End Sub
3. To resolve errors with the flags visOpenDocked and visOpenCopy, append VisOpenSaveArgs to each flag. If VisOpenSaveArgs is not used, Visual Studio shows errors such as "Name 'visOpenDocked' is not declared."
Imports Microsoft.Office.Interop.Visio
Public Class ThisAddIn
Private vsoDoc As Visio.Document
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs ) _
Handles Me.Startup
vsoDoc = Application.Documents.Add("")
vsoDoc = Application.Documents.OpenEx("Basic Shapes.vss", _
VisOpenSaveArgs.visOpenDocked + VisOpenSaveArgs.visOpenCopy)
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Shutdown
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Shutdown
End Sub
P.S Test following codes and see the difference with the above codes
Imports Microsoft.Office.Interop.Visio
Public Class ThisAddIn
Private vsoDoc As Visio.Document
Private Sub ThisAddIn_Startup(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Startup
vsoDoc = Application.Documents.Add("")
vsoDoc = Application.Documents.add("Basic Shapes.vss")
End Sub
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Shutdown
End Sub
End Class
Private Sub ThisAddIn_Shutdown(ByVal sender As Object, _
ByVal e As System.EventArgs) _
Handles Me.Shutdown
End Sub
End Class
댓글 없음:
댓글 쓰기