VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Help - VBA Issues

3 REPLIES 3
Reply
Message 1 of 4
mboyer
305 Views, 3 Replies

Help - VBA Issues

Trying to run a VBA routine that has worked fine in AutoCAD 2008 but now gives me the following error when running in AutoCAD 2009.

FATAL ERROR: Unhandled Access Violation Writing 0x80534a4d Exception at 650bd6d3h

What the program does:
We have a prototype set of drawings that are stored in a network location. The routine will create a new set of drawings using database entries in Microsoft Access 2003. It works fine up until the same drawing each time. I've checked the drawing and find no issues w/ it. Interestingly, if I create a new dwg w/ the same name, it will process. Could there be content within a drawing that prevents it from being "Saved As" during a vba routine?
Code is listed below.

Private Sub GetFileNames()

Dim strFileName As String
Dim strFilePath As String
Dim strTempName As String
Dim strNewFName As String
Dim strNewPath As String
Dim strPath As String
Dim WS As Workspace
Dim DB As Database
Dim RS As Recordset



DBName = "Templates"
WSName = "M:\DesignForum\database\" + txtWSName.Text

Set WS = DBEngine.Workspaces(0)
Set DB = WS.OpenDatabase(WSName)
Set RS = DB.OpenRecordset(DBName, dbOpenTable)

strFilePath = ThisDrawing.Path

Do While Not RS.EOF
strPath = RS!TemplatePathName
strTempName = RS!TemplateFileName
strFileName = strPath + strTempName
strNewFName = strFilePath + "\" + txtJobNo + "_" + strTempName
ThisDrawing.Application.Documents.Open (strFileName)
ThisDrawing.SaveAs (strNewFName)
ReplacePaths
ThisDrawing.SaveAs (strNewFName)
ThisDrawing.Close
RS.MoveNext
Loop
End Sub
3 REPLIES 3
Message 2 of 4
borgunit2003
in reply to: mboyer

Just as a check, have you stepped through each line of code with F8 and which line of code crashes it?

http://mechcad-insider.blogspot.com/
Message 3 of 4
mboyer
in reply to: mboyer

It seems to be at the line which does a Save As.
Message 4 of 4
rstrandmark
in reply to: mboyer

>Try all of these typical things and see if it helps.
-pu r * n
-pu all n (until everything is purged)
audit
recover
(repeat process until everything is purged and no audit errors)

>If that doesn't help, in each environment (mspace, pspace, etc.):
Erase All
Undo
>then...
Save, Close, Reopen
>then....
-pu r * n
-pu all (untill everything is purged)
audit
recover

You can also try saving to a different dwg version then back, if you can, which may rewrite parts of the file that may be corrupted.

If all else fails... rebuild the file from a new one.

Good luck!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost