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

One Error was found in the drawing file during open - using VBA & Attributes

0 REPLIES 0
Reply
Message 1 of 1
Hawthorn76
578 Views, 0 Replies

One Error was found in the drawing file during open - using VBA & Attributes

I have developed a program in Access 2010 that uses VBA to open up an autocad file and write to 4 different attributes. After the change has been made, it saves and closes the file. 

 

When using AutoCAD 2012 and I open the file for the first time, it creates the following error 

One Error was found in the drawing file during open Would you like to cancel this open?

 

This does not occur with AutoCAD 2013 or when i step through the program (using F8 on keyboard ) using AutoCAD 2012.

 

The code is as follows:

 

Private Sub CmdUploadSigDatetoDwgs_Click()

 

Call GetFilePath 'Return File and Path Name and place in array

 

RecordCounter = 0

 

On Error Resume Next

'if autocad is already open run this
Set acApp = GetObject(, "AutoCAD.Application")

 

If Err.Number <> 0 Then 'Not Running
    Set acApp = CreateObject("AutoCAD.Application")
    Err.Clear
    CloseAutoCAD = True
Else
    'Variable to not close autocad
    CloseAutoCAD = False
End If

 

acApp.Visible = False 'Display / Hide AutoCAD. sometimes crashes

 

'Loop through Array and return File and Path

For RecordCounter = LBound(FilePathArray) To UBound(FilePathArray)

    FilePathName = FilePathArray(RecordCounter)

    Set aDoc = acApp.Documents.Open(FilePathName)

    For Each po_obj In aDoc.PaperSpace 
        

         If TypeOf po_obj Is AcadBlockReference Then 

               

               If po_obj.HasAttributes Then

                     

                     For CounterNest1 = LBound(att1) To UBound(att1)

                     

                          Select Case att1(CounterNest1).TagString
                                Case "APP"
                                           att1(CounterNest1).TextString = Me.TxtApprovedBy
                                Case "APPDATE"
                                           att1(CounterNest1).TextString = CStr(Me.TxtApprovedByDate)
                               Case "CKD"
                                          att1(CounterNest1).TextString = Me.TxtCheckedBy
                               Case "CKDDATE"
                                         att1(CounterNest1).TextString = CStr(Me.TxtCheckedByDate)
                               End Select

 

                     Next CounterNest1 

 

               End if

         

         End if

   

Next 


aDoc.Close True, FilePathName

 

Next RecordCounter

 

If CloseAutoCAD = True Then
    acApp.Quit 'Close autoCAD automation
Else
    acApp.WindowState = acMin
End If

 

Set aDoc = Nothing
Set acApp = Nothing

 

End Sub

 

I would appreciate if someone can guide me to a solution,

 

Thanks

 

 

 

 

 

 

0 REPLIES 0

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

Post to forums  

Autodesk Design & Make Report

”Boost