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

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

11 REPLIES 11
SOLVED
Reply
Message 1 of 12
burodemunnynck
17725 Views, 11 Replies

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

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

11 REPLIES 11
Message 2 of 12

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 3 of 12

Hi Alfred,

 

 

thanks for your time spending on this issue!

 

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

 

 

Gr

Frank

Message 4 of 12

Hi,

 

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

 

- alfred -

------------------------------------------------------------------------------------
Alfred NESWADBA
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 5 of 12

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

Message 6 of 12

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 7 of 12

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

Message 8 of 12

Alfred,

 

this works!

But you didn't use this, right?

 

Dim acadApp As AcadApplication
Set acadApp = ThisDrawing.Application

 

G

F

Message 9 of 12

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
Ingenieur Studio HOLLAUS ... www.hollaus.at ... blog.hollaus.at ... CDay 2024
------------------------------------------------------------------------------------
(not an Autodesk consultant)
Message 10 of 12

Hi Alfred,

 

 

everything is working now, thanks a lot!

 

Gr

F

Message 11 of 12

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

 

Message 12 of 12

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

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

Post to forums  

Autodesk Design & Make Report

”Boost