Open dxf after run macro - Autocad 2019

Open dxf after run macro - Autocad 2019

Anonymous
Not applicable
1,430 Views
4 Replies
Message 1 of 5

Open dxf after run macro - Autocad 2019

Anonymous
Not applicable

Hello guys,

 

if got a strange new problem on my existing vba codes. I had a code to close all drawings without saving that works fine with autocad 2018. Actually the code works even well with autocad 2019, but one time used I cannot open a dxf file to autocad from the file explorer anymore.

Private Sub CommandButton12_Click()
    'Unload Auswahl
    Dim Drawing As AcadDocument
    For Each Drawing In Application.Documents
        Drawing.Close False
    Next
End Sub

The only thing you could do to be able to open files by double clicking in the file explorer is to push the "stop" button in the vba environment toolbar or to add an "End" to the code.

 

I there anybody who could explain this? I tried it on two workstations with the actual autocad 2019.

 

Thanks in advance!

Lars

0 Likes
Accepted solutions (1)
1,431 Views
4 Replies
Replies (4)
Message 2 of 5

Anonymous
Not applicable

Has anybody the same problem or can readjust this issue?

0 Likes
Message 3 of 5

Ed__Jobe
Mentor
Mentor

I may not understand your problem or you haven't provided enough information, but opening a file shouldn't have anything to do with your code. Unless, you're trying to open a file while the command is in progress. AutoCAD can only run one command at a time.

Ed


Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
How to post your code.

EESignature

0 Likes
Message 4 of 5

Anonymous
Not applicable

Well I would completely agree with you that my code has nothing to do with open a file, but in fact there must be any effect:

1. I open a dxf-file by doubleclicking in the file explorer. If there is a running autocad session the file is opened in autocad, otherwise auotcad is started.

2. I run the code as descriped above(In fact every code with which deals with "SendCommand" seems to have this influenece.)

3. I try again to open any file by doubleclicking or "open with" in the file explorer and nothing happens. This is the same with other filetypes (e.g. dwg) as well.

4. To be able to open files from file explorer again, I reset the vba environment by pushing the "Stop" Button. After that open files works again..

grafik.png

 

Maybe I have a problem with the standard programm to open dxf files, which I cannot imagine because in the first step it works fine.

0 Likes
Message 5 of 5

Anonymous
Not applicable
Accepted solution

Well after testing a bit I changed the code slightly to a solution that works:

Private Sub CommandButton17_Click()
    Dim Drawing As AcadDocument
    For Each Drawing In Application.Documents
        Drawing.SendCommand "_qsave" & vbCr
        AcadApplication.Documents.Close False
    Next
End Sub

There seems to be a influence through the so called zero document state which causes my problems. For further information take a look here:

https://knowledge.autodesk.com/search-result/caas/CloudHelp/cloudhelp/2016/ENU/AutoCAD-ActiveX/files...

 

Lars

 

0 Likes