Search code examples
excelvbacadnano

excel VBA to open NanoCAD application


I wanted to try out automating multiple drawings generation in NanoCAD. there are many sources to help with AutoCAD, but not much with NanoCAD. for Example, can some one give me a equivalent code for below (which we can use to open Autocad) to open NanoCAD ?

I have the references to the NanoCAD commands done properly. like we do for Autocad.

Sub opencad()
    Dim ACAD As AcadApplication 'Create ACAD variable of type AcadApplication
    On Error Resume Next 
    Set ACAD = GetObject(, "AutoCAD.Application") 
    On Error GoTo 0 
    If ACAD Is Nothing Then 
        Set ACAD = New AcadApplication 
        ACAD.Visible = True 
    End If
    ACAD.ActiveDocument.Utility.Prompt "ZOOM ALL " 
End Sub

Solution

  • You have to use such code:

    Dim app As nanoCAD.Application
    Set app = GetObject("", "nanoCAD.Application")
    

    Also don't forget to include nanoCAD type lib (NCAuto.dll) into your project (menu Tools - Reference..)