![open autocad file open autocad file](https://i2.wp.com/www.firstinarchitecture.co.uk/wp-content/uploads/2018/03/SketchUp-FAQ-01-FI.jpg)
Target = UCase(Cells(i, 1).Value) 'Get Targeted Cell Value
Open autocad file code#
Using the above code as a starting point and applying it to the OP's code, you would end up with the following: Option Explicit Note the modification of the GetObject call and how the document is being opened. MsgBox "AutoCAD must be running before performing this action.", vbCritical Set a = CreateObject("AutoCAD.Application") Set a = GetObject(, "AutoCAD.Application") Here is a basic shell of what I use in our production application: Sub Open_Dwg() If Wildcard "" Then 'If Not Then Use Wildcardįunction OpenFile(ByVal ACADPath As String) As String Wildcard = Dir(path & SplitString(1) & "*.dwg") 'File Path and Wildcard OpenString = path & SplitString(1) & ".dwg" 'File Path and Name Path = path & "\" & SplitString(0) & "\" 'Build Complete Path SplitString() = Split(target, "-", 2) 'Split given name to obtain subfolder and name Target = UCase(target) 'All Letters to Upper Case Target = Cells(i, 1).Value 'Get Targeted Cell Value Path = "C:\Users\aholiday\Desktop\DEMO" 'Root Folder Set ACAD = GetObject(, "AutoCAD.Application") MsgBox "Could not start AutoCAD.", vbCritical Set ACAD = CreateObject("AutoCad.Application") The Open method opens an existing drawing file. The Add method creates a new drawing file based on a drawing template and adds that drawing to the DocumentCollectionExtension. UPDATED Code below: Dim ACADApp As AcadApplication To create a new drawing or open an existing drawing, use the methods of the DocumentCollectionExtension object.
![open autocad file open autocad file](https://charlottekawevq.weebly.com/uploads/1/3/8/4/138478289/845243063_orig.jpg)
The issue is that it will open one drawing (first in the list) but will error out with "Run time error '438': Object doesn't support this property or method" It will not continue past Set ACADApp.ActiveDocument = (ACADPath) to open the other dwgs in the list The code is supposed to first check if AutoCAD is opened, if so then open the dwg in the opened AutoCAD application, if not then open a new application. However sometimes descriptions of the part are added in parenthesis so for example 1001-01 (Chuck). 01T is the subfolder name and the 1001-01 is the file name, it splits at. From the first half the code finds the subfolder that contains that category of part numbers then the second half is the actual file name. On running, the code splits the first part number typed. I have an excel file with part numbers listed in a column.