Visual Basic Customization

Visual Basic Customization

Reply
Active Member
mboyer
Posts: 10
Registered: ‎11-13-2006
Message 1 of 4 (94 Views)

Help - VBA Issues

94 Views, 3 Replies
05-20-2008 12:57 PM
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
Distinguished Contributor
borgunit
Posts: 150
Registered: ‎01-04-2007
Message 2 of 4 (94 Views)

Re: Help - VBA Issues

05-21-2008 05:10 AM 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/
Active Member
mboyer
Posts: 10
Registered: ‎11-13-2006
Message 3 of 4 (94 Views)

Re: Help - VBA Issues

05-22-2008 07:50 AM in reply to: mboyer
It seems to be at the line which does a Save As.
Valued Contributor
rstrandmark
Posts: 73
Registered: ‎11-01-2006
Message 4 of 4 (94 Views)

Re: Help - VBA Issues

05-22-2008 02:18 PM 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!
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Need installation help?

Start with some of our most frequented solutions or visit the Installation and Licensing Forum to get help installing your software.