Autocad _VBA

Autocad _VBA

Anonymous
Not applicable
2,022 Views
3 Replies
Message 1 of 4

Autocad _VBA

Anonymous
Not applicable

Hi

 

I try to update the AutoCAD attribute by excel VBA uses the below code.

 


Dim acadApp As AcadApplication

'On Error Resume Next

Set acadApp = GetObject(, AcAppClID)

If acadApp Is Nothing Then

Set acadApp = CreateObject(AcAppClID)

End If

acadApp.Visible = False

Dim Document As AcadDocument

 

i get the error message "run-time error 429 activex component can't create object"

 

Pls help

 

0 Likes
2,023 Views
3 Replies
Replies (3)
Message 2 of 4

grobnik
Collaborator
Collaborator

Hi @Anonymous 

I'm suggesting to check your Excel Code as below example, I guess your code Set acadApp = GetObject(, AcAppClID) it's not correct, if you do not defined the Variable AcAppClID before, in any case should be better apply the canonic standard code.

 

 

Sub Opendwg()
    Dim acadApp As Object
    Dim acadDoc As Object
'Check if AutoCAD is open.
    On Error Resume Next
    Set acadApp = GetObject(, "AutoCAD.Application")
    On Error GoTo 0
    
    'If AutoCAD is not opened create a new instance and make it visible.
    If acadApp Is Nothing Then
        Set acadApp = CreateObject("AutoCAD.Application")
        acadApp.Visible = True
    End If
    
    'Check if there is an active drawing.
    On Error Resume Next
    Set acadDoc = acadApp.ActiveDocument
    On Error GoTo 0
    
    'No active drawing found. Create a new one.
    If acadDoc Is Nothing Then
        Set acadDoc = acadApp.Documents.Add
        acadApp.Visible = True
    End If

End Sub

 

 

 Let us know

0 Likes
Message 3 of 4

Anonymous
Not applicable

Hi @grobnik  

Thank you for your reply. Already  Variable AcAppClID. Attached image for your reference.

 

agowri_0-1607143771462.png

 

I try your code also, it's also showing the error. The image is attached for reference.

agowri_1-1607144626498.png

Thanks.

 

 

0 Likes
Message 4 of 4

grobnik
Collaborator
Collaborator

Hi @Anonymous ,

thank you for your message, seems very strange as error type and in any case it's quiet different from previous one you got, so it's not related to an ActiveX issue, but to "elevation" that it's not mentioned or settled inside the code.

Could be a silly question but you should develop software inside Excel, and as second issue are you able to execute my code step by step (F8) and highlight where the code hangs ?.

As third issue you can make an image of project reference inside Excel ? like picture below ?

grobnik_0-1607150794462.png

Bye, 

0 Likes