Yes indeed, this one is to be a stand-alone. I think I found something on a post from several years ago on the Autodesk Forum. I have adjusted it for my needs here....and the original one had a GoTo in it. If I recall correctly, the GoTo statement is bad practice. I recall taking a C++ class way back in 1992 and the teacher told the first thing he was going to do was to take away our GoTo. Here is the code I've tested and it seems to be working like I need it...sans some additional error handling. I only needed the AutoCAD 2013 Type Libraries for this to work. This will eventually be in a WAF so the user can select which of about a dozen different templates we have available.
Imports AutoCAD
Imports AutoCAD.AcadDocumentClass
Module Module1
Sub Main()
Dim vAcadApp, vNewFile As Object
Dim strNovellPath As String = "\\my_novell_path\dwg\"
Dim strFileName As String = "drawing templates(xx).dwg"
On Error Resume Next
vAcadApp = GetObject(, "autocad.Application")
If Err.Number <> 0 Then
Err.Clear()
vAcadApp = CreateObject("autocad.Application")
End If
vAcadApp.Visible = True
Err.Clear()
vNewFile = vAcadApp.Documents.Open(strNovellPath & strFileName, False)
End Sub
End Module
This will open the existing drawing I'm wanting and if AutoCAD is already running it uses that instance of it, even if there are other drawings open in that instance, this one will be come the Active drawing. If AutoCAD is not running it will start it up and then open the requested drawing. I would appreciate anyone helping me to add the correct error handling in this. I'm still new to a lot of this .NET format.