File fails to save

File fails to save

Anonymous
Not applicable
1,790 Views
9 Replies
Message 1 of 10

File fails to save

Anonymous
Not applicable
I'm working on some code to save a DXF file after modification as a R12 DXF, but I'm having problems with the "SaveAs" function. Part of the code is below (just watch out for broken lines). It fails at the last line below.

Any suggestions?


MsgBox ThisDrawing.FullName
If (ThisDrawing.FullName = "") Or StrComp("DWG", UCase(Right(ThisDrawing.FullName, 3))) = 0 Then
SaveFile
Exit Sub
End If

Dim dteCreate As Date
Dim dteAccess As Date
Dim dteModify As Date

If Not modTime.GetFileTimes(ThisDrawing.FullName, dteCreate, dteAccess, dteModify, True) Then
Call MsgBox("Error getting file dates.", vbCritical, "Unable to Read File Dates")
Exit Sub
End If

MsgBox "Modified date: " & dteModify
oldDateMod = dteModify

ThisDrawing.SaveAs ThisDrawing.FullName, acR12_dxf
0 Likes
1,791 Views
9 Replies
Replies (9)
Message 2 of 10

Anonymous
Not applicable
there seems to be some logic error.

shouldn't this

If (ThisDrawing.FullName = "")

be this

If (ThisDrawing.FullName <> "")

because i think that the fullname property is not set to anything and
therefore your SaveAs method will fail. i don't think you need the DWG part
of the statement.


wrote in message news:5840255@discussion.autodesk.com...
I'm working on some code to save a DXF file after modification as a R12 DXF,
but I'm having problems with the "SaveAs" function. Part of the code is
below (just watch out for broken lines). It fails at the last line below.

Any suggestions?


MsgBox ThisDrawing.FullName
If (ThisDrawing.FullName = "") Or StrComp("DWG",
UCase(Right(ThisDrawing.FullName, 3))) = 0 Then
SaveFile
Exit Sub
End If

Dim dteCreate As Date
Dim dteAccess As Date
Dim dteModify As Date

If Not modTime.GetFileTimes(ThisDrawing.FullName, dteCreate, dteAccess,
dteModify, True) Then
Call MsgBox("Error getting file dates.", vbCritical, "Unable to Read
File Dates")
Exit Sub
End If

MsgBox "Modified date: " & dteModify
oldDateMod = dteModify

ThisDrawing.SaveAs ThisDrawing.FullName, acR12_dxf
0 Likes
Message 3 of 10

Anonymous
Not applicable
Thought logic was OK.

The full code (not included) is intended to work only on existing DXF files loaded into ACAD for modification. So a new drawing won't have a name until saved, and I don't want the code to work on a DWG. Hence the code :-

If (ThisDrawing.FullName = "") Or StrComp("DWG", UCase(Right(ThisDrawing.FullName, 3))) = 0 Then
SaveFile 'gets the windows save dialog
Exit Sub 'so we don't get to the later ThisDrawing.SaveAs
End If
0 Likes
Message 4 of 10

Anonymous
Not applicable
what is the exact error message you are getting? what version of ac are you
running this code on?

wrote in message news:5840341@discussion.autodesk.com...
Thought logic was OK.

The full code (not included) is intended to work only on existing DXF files
loaded into ACAD for modification. So a new drawing won't have a name until
saved, and I don't want the code to work on a DWG. Hence the code :-

If (ThisDrawing.FullName = "") Or StrComp("DWG",
UCase(Right(ThisDrawing.FullName, 3))) = 0 Then
SaveFile 'gets the windows save dialog
Exit Sub 'so we don't get to the later ThisDrawing.SaveAs
End If
0 Likes
Message 5 of 10

Anonymous
Not applicable
The error message is a very helpful dialog box with "Error saving document" message. If I click the HELP button "Help topic does not exist". All very helpful!

This is in both ACAD 2004 and ACAD Mechanical 2007.
0 Likes
Message 6 of 10

Anonymous
Not applicable
try supplying a filename for the saveas operation instead of using the
Fullname property and see what happens. i still think it is failing because
you are not supplying a valid filename.

wrote in message news:5840347@discussion.autodesk.com...
The error message is a very helpful dialog box with "Error saving document"
message. If I click the HELP button "Help topic does not exist". All very
helpful!

This is in both ACAD 2004 and ACAD Mechanical 2007.
0 Likes
Message 7 of 10

Anonymous
Not applicable
If I use "C:\testDrawing.DXF", it still doesn't work but I get a different error message!

Run-time error '-2145320861 (80210063)'
Error saving the document
0 Likes
Message 8 of 10

Anonymous
Not applicable
So I created a new sub and typed all the same code in again and now it WORKS!

'B....' computers!!!!!
0 Likes
Message 9 of 10

Anonymous
Not applicable
wrote in message news:5840692@discussion.autodesk.com...
So I created a new sub and typed all the same code in again and now it
WORKS!

'B....' computers!!!!!

welcome to acad vba
:-)
0 Likes
Message 10 of 10

Anonymous
Not applicable
Much the same as Inventor VBA then........
0 Likes