Macro to open specific file

Macro to open specific file

Anonymous
Not applicable
3,900 Views
13 Replies
Message 1 of 14

Macro to open specific file

Anonymous
Not applicable

I am trying to open file using macro button, i have added it in menu but the drawings are not opening directly from the button click. Autocad replied me "Cannot find the specified drawing file. Please verify that the file exists"

Also i have added path in Support file search path.

script = ^C^C_setvar;filedia;0;_fileopen;Computer/Shared Data/M/8.IDEAS TO WORK FAST/Standard Components/Fastener.dwg;_setvar;filedia;1;

 

File path = Capture.PNG

0 Likes
Accepted solutions (2)
3,901 Views
13 Replies
Replies (13)
Message 2 of 14

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

when you type this into the Windows Explorer address line, it doesn't work, does it?

Computer/Shared Data/M/8.IDEAS TO WORK FAST/Standard

You should use a valid filename with the correct path and extension.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 14

Anonymous
Not applicable

^C^C_setvar;filedia;0;_fileopen;Computer/M:/M/8. IDEAS TO WORK FAST/Standard Components/Fastener.dwg;_setvar;filedia;1;

 

Using above path, its open in windows explorer.

there are four dwg files in that standard components file

 

NEW PATH=Capture.PNG

0 Likes
Message 4 of 14

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

>> Using above path, its open in windows explorer.

The real filename specification starts with

M:

or

\\192.168.20.10

(not with "Computer")

So the folder you can use is:
M:/M/8. IDEAS TO WORK FAST/Standard Components/Fastener.dwg

 

So the complete statement should be (with quotes, as you have spaces in the filename):

^C^C_FILEOPEN;"M:/M/8. IDEAS TO WORK FAST/Standard Components/Fastener.dwg"

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 5 of 14

Jonathan3891
Advisor
Advisor

Try using the "STARTAPP" command. It will start any external application as well as open drawings.

I find that this is much easier than other methods.

 

(startapp "explorer" (findfile "your/path/here/filename.dwg"))

 


Jonathan Norton
Blog | Linkedin
Message 6 of 14

Anonymous
Not applicable

Thank you Sir, it's working...

now i am facing some issue, when i click on that macro button to open specific file. the files which is already open in autocad are automatically closed & then open that file which i wanted to open with that macro button...... 

For ex.....XYZ file is now open in my autocad & then i click on macro button to open ABC file...then autocad automatic closed XYZ file & then open ABC.....so don't want to close XYZ file that time.

0 Likes
Message 7 of 14

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

>> the files which is already open in autocad are automatically closed

You have started with command _FILEOPEN .. that only works when SDI is active, so you are not working in SDI mode 1?

SDI 1 means you can only have one file open, that's why an already opened file closes before.

 

But @Jonathan3891 has shown a great alternative, use this instead _FILEOPEN

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 8 of 14

Anonymous
Not applicable

So....there are no any option without this in macro to open specific file in autocad (Without closed any cad file)

0 Likes
Message 9 of 14

Paul_Gander
Advocate
Advocate

Create a Script file with the following line:

_OPEN "M:/M/8. IDEAS TO WORK FAST/Standard Components/Fastener.dwg"

Save it as something like "open fastener dwg.scr" and then you can create a macro to run the script:

^C^C_SCRIPT;"open fastener dwg"
0 Likes
Message 10 of 14

Anonymous
Not applicable

I tried it but autocad reply me like.....Capture.PNG

0 Likes
Message 11 of 14

Paul_Gander
Advocate
Advocate

Sorry, I should have mentioned that the script file needs to be saved in a support folder listed in the Support Search File Path so that AutoCAD can find it.


If you don't already have your own support folder set up, Start the command OPTIONs, click on the Files tab and expand the Support File Search Path to see the list of folders. Save the script file in one of the folders listed or create your own folder and add it to the list.

 

You may also need to ensure that the folder is listed under Trusted Locations.

 

Or you could specify the full path of the script file in the SCRIPT command in the macro.

0 Likes
Message 12 of 14

Anonymous
Not applicable

Please see attached screen cast .....Autocad replying me to add drawing name

0 Likes
Message 13 of 14

cadffm
Consultant
Consultant
Accepted solution

Seems you  forgot to enter the input..

After you are type in the path (or better, the script send the path to the commandline),

you need a ENTER hit to send it from commandline-field  to the AutoCAD-brain.

 

So i guess, you forgot the linebreak after your path in your script!

 

This Script has THREE lines:

_OPEN
"D:/M/8. MyShortPath/Fastener.dwg"

 

 

 

Sebastian

0 Likes
Message 14 of 14

Anonymous
Not applicable

It's Working.......Thank you very much for your Quick guidance & support......

0 Likes