Author Topic: Automation Error: Cannot Save File  (Read 3280 times)

0 Members and 1 Guest are viewing this topic.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Automation Error: Cannot Save File
« on: February 28, 2005, 09:07:31 AM »
Ok .. I must admit, this one has me stumped ... I'll give the scenario and you can test it on your installation to see if the result is the same...

Scenario:
VBA Automation to open DXF file and back up the version to R12

User selects file via Common Dialog (found elsewhere on this forum)
VBA directs AutoCAD to open the DXF file and make it the active drawing
VBA attempts a saveas to a previous version and the error happens...

Code: [Select]

Sub DXF2R12()
 Set DXFDoc = Application.Documents.Open ("C:\MYFILE.DXF")
 DXFDoc.Saveas "C:\MYFILE.DXF", acR12_dxf
End Sub


Anyway, there is no problem if saving "dwg to dwg", "dwg to dxf" or "dxf to dwg" only "dxf to dxf" fails ...
In the meantime I have resolved the issue by using this workaround ...

Code: [Select]

Sub DXF2R12()
 Set DXFDoc = Application.Documents.Open ("C:\MYFILE.DXF")
 DXFDoc.Saveas Environ("TEMP") & "\MYFILE.DWG, acR15_dwg
 DXFDoc.Saveas "C:\MYFILE.DXF, acR12_dxf
 Kill Environ("TEMP") & "\MYFILE.DWG"
End Sub
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

hendie

  • Guest
Automation Error: Cannot Save File
« Reply #1 on: February 28, 2005, 10:16:50 AM »
I get the same error Keith.
Another workaround would be to use filecopy on the DXF before opening it but you would still have to kill a file after the routine ended

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Automation Error: Cannot Save File
« Reply #2 on: February 28, 2005, 10:46:41 AM »
Incedently I found a couple more quirks with this ...

you can save a dwg to dxf, then reopen the dwg and save back to the same dxf without incident, so this would seem to indicate a file lock issue ... it is almost as if AutoCAD places a file lock on the DXF when opening a DXF that is not removed prior to saving the file to DXF...
I think I am going to try using the save option on a DXF but I seem to remember that by doing so, AutoCAD defaults to the current DWG version for the save version.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie