Set ACADApp = GetObject(, "AutoCAD.Application")

Set ACADApp = GetObject(, "AutoCAD.Application")

burodemunnynck
Contributor Contributor
19,340 Views
11 Replies
Message 1 of 12

Set ACADApp = GetObject(, "AutoCAD.Application")

burodemunnynck
Contributor
Contributor

Hi all,

 

just downloaded and installed the new autocad2013 64bit. Glad to see there is indeed a vba-enabler after all! 

I have a routine in vba, written in earlier versions of autocad. And it won't work anymore: this is where things go wrong:

Set ACADApp = GetObject(, "AutoCAD.Application")

 

Also in others programs certain things don't work: creating layers, rotating text, inserting blocks etc

 

 

Is there anyone who can help me fixing this, won't be difficult for vba gurus i suppose.

 

Thanks!

 

Gr

Frank

0 Likes
Accepted solutions (1)
19,341 Views
11 Replies
Replies (11)
Message 2 of 12

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

if you are in VBA for AutoCAD (not within Excel or some external prog) you should use:

Dim acadApp as AcadApplication

Set acadApp = ThisDrawing.Application

 

With your statement (using GetObject...) the operating system scans for the first AutoCAD-process and returns it's ActiveX-connection-object. If you have started more than one AutoCAD you may get the wrong process returned.

 

>> Also in others programs certain things don't work

Verify in your references that you have set the AutoCAD-specific references to the current (19.0) lib's.

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 3 of 12

burodemunnynck
Contributor
Contributor

Hi Alfred,

 

 

thanks for your time spending on this issue!

 

i still get the same error: run time error '13' - type mismatch

 

 

Gr

Frank

0 Likes
Message 4 of 12

Alfred.NESWADBA
Consultant
Consultant
Accepted solution

Hi,

 

have you checked the references? Are they all set for AutoCAD 2013 (then saved the DVB and restarted AutoCAD?)

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 5 of 12

burodemunnynck
Contributor
Contributor

which references should be checked? I

These are checked now:

autocad 2013 type library

ole automation

visual basic for applications

 

In a few vba programs the reference is protected by a password. I can't remember me setting there a password. There is a password however on each vba program.

 

Gr

Frank

0 Likes
Message 6 of 12

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

I created now a little test, creating a new layer and a line on this layer.

Start your AutoCAD, load and try my DVB ..... does that work on your pc?

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
0 Likes
Message 7 of 12

burodemunnynck
Contributor
Contributor

things now go pretty well with these references checked. By checking the autocad2013 reference, it seems that is no longer possible to run the routine in autocad2012, and autocad doesn't let you check both 2012 and 2013 references.

 

G

F

0 Likes
Message 8 of 12

burodemunnynck
Contributor
Contributor

Alfred,

 

this works!

But you didn't use this, right?

 

Dim acadApp As AcadApplication
Set acadApp = ThisDrawing.Application

 

G

F

0 Likes
Message 9 of 12

Alfred.NESWADBA
Consultant
Consultant

Hi,

 

if I add these lines:

 

Private WithEvents acadApp As AcadApplication

Public Sub initAppEvents()
   Set acadApp = ThisDrawing.Application
End Sub
Private Sub acadApp_SysVarChanged(ByVal SysvarName As String, ByVal newVal As Variant)
   Call MsgBox("Sysvar changed: " & SysvarName)
End Sub

 

I have no problem to run  initAppEvents  and I also get then the events fired.

 

 - alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
ISH-Solutions GmbH / Ingenieur Studio HOLLAUS
www.ish-solutions.at ... blog.ish-solutions.at ... LinkedIn ... CDay 2026
------------------------------------------------------------------------------------

(not an Autodesk consultant)
Message 10 of 12

burodemunnynck
Contributor
Contributor

Hi Alfred,

 

 

everything is working now, thanks a lot!

 

Gr

F

0 Likes
Message 11 of 12

Anonymous
Not applicable

Works on x32 but don't on x64 Error on "

Application.Update

"

Sub StartWorkWithDB()

Dim sPath As String
On Error GoTo NoDbOpened
sPath = GetDBName
If OpenMDB(sPath) = False Then GoTo NoDbOpened
  ThisDrawing.SetVariable "sdi", 1
  ThisDrawing.SetVariable "cmdecho", 0
  frmDBUtils.Show

    frmDBUtils.lblInfo.Caption = "Áàçà äàíèõ ï³äêëþ÷åíà"
    frmDBUtils.cbGetCode.Visible = False
    frmDBUtils.cbRegister.Visible = False

Revision
frmDBUtils.LoadAgroType
frmDBUtils.LoadAgro (frmDBUtils.cbxAgroType.Value)
frmDBUtils.cbSelectAgro.Enabled = True
frmDBUtils.cbShowAgro.Enabled = True
frmDBUtils.cbAudit.Enabled = True
 If verifylayer("$Dil") = False Then
   ThisDrawing.Layers.Add ("$Dil")
 End If
 If verifylayer("$laypo") = False Then
   ThisDrawing.Layers.Add ("$laypo")
 End If
 If verifylayer("$kvartal") = False Then
   ThisDrawing.Layers.Add ("$kvartal")
 End If
'Application.Update 'Autocad 2008 - works on x32


'--------tmp
AcadApplication.Update ' dont work



Exit Sub
NoDbOpened:
End Sub

 

0 Likes
Message 12 of 12

Anonymous
Not applicable

If i dell "Application.Update" I can press the button on my form from 10 click mouse or 1000. I don't know why?

0 Likes