Im playing around with VBA code from this microsoft help site that adds shapes to a visio document. However I can't get the code to work as shown on the website. Here is the website with the code: https://msdn.microsoft.com/en-us/library/cc160744.aspx?cs-save-lang=1&cs-lang=csharp#code-snippet-1
Here is what I have currently:
Imports Microsoft.Office.Interop
Module Module1
Public Property Application As Object
Sub Main()
Dim names As New List(Of String)()
Application.Documents.Add("")
Dim visioDocs As Visio.Documents
Dim visioStencil As Visio.Document = visioDocs.OpenEx("Basic Shapes.vss", CShort(Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenDocked))
Dim visioPage As Visio.Page = Application.ActivePage
Dim visioRectMaster As Visio.Master = visioStencil.Masters("Rectangle")
Dim visioRectShape As Visio.Shape = visioPage.Drop(visioRectMaster, 4.25, 5.5)
visioRectShape.Text = "Rectangle text."
Dim visioStarMaster As Visio.Master = visioStencil.Masters("Star 7")
Dim visioStarShape As Visio.Shape = visioPage.Drop(visioStarMaster, 2.0, 5.5)
visioStarShape.Text = "Star text."
Dim visioHexagonMaster As Visio.Master = visioStencil.Masters("Hexagon")
Dim visioHexagonShape As Visio.Shape = visioPage.Drop(visioHexagonMaster, 7.0, 5.5)
visioHexagonShape.Text = "Hexagon text."
End Sub
End Module
I get a null reference exception failed to handle at the end of the Application.Documents.Add("") line. I've tried many solutions via google but have not been able to get rid of the error. Any ideas on how to get this to run?