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
Solved! Go to Solution.
Solved by Alfred.NESWADBA. Go to Solution.
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 -
Hi Alfred,
thanks for your time spending on this issue!
i still get the same error: run time error '13' - type mismatch
Gr
Frank
Hi,
have you checked the references? Are they all set for AutoCAD 2013 (then saved the DVB and restarted AutoCAD?)
- alfred -
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
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 -
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
Alfred,
this works!
But you didn't use this, right?
Dim acadApp As AcadApplication
Set acadApp = ThisDrawing.Application
G
F
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 -
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
If i dell "Application.Update" I can press the button on my form from 10 click mouse or 1000. I don't know why?