-
AutoCAD 2007 - Run routine when opening dwg
Simply put, I want to have AutoCAD run a vba routine whenever a drawing is openned.
Thanks to some help from this site, I have a routine that works for CAD 2000, but I am getting error messages in 2007.
Here is the code I have that works in 2000:
In the ThisDrawing tab:
[vba]
Dim Aok As Class1
Private Sub AcadDocument_Activate()
If Aok Is Nothing Then Set Aok = New Class1
If IsEmpty(ACADApp) Then Aok.AcadApplication_Events
End Sub
[/vba]
in the Class Modules tab:
[vba]
Public WithEvents ACADApp As AcadApplication
Public Sub AcadApplication_Events()
Set ACADApp = GetObject(, "AutoCAD.Application")
End Sub
Private Sub ACADApp_EndOpen(ByVal filename As String)
RunMacro "AddaBlock.XrefUpdate"
End Sub
[/vba]
and in the modules tab..
[vba]
Sub XrefUpdate()
..code...
End Sub
[/vba]
TIA for any help
-
Just an idea only because I have not have A2007
Change this line:
[vba]Set ACADApp = GetObject(, "AutoCAD.Application")[/vba]
on
[vba]
Set ACADApp = GetObject(, "AutoCAD.Application.17")
[/vba]
HTH
Fatty
~'J'~
-
here is to hoping the module name is "AddaBlock".
Where is the error?
What does it say?
-
The error has been resolved. Apparently VBA and/or AutoCAD doesn't like when you have 2000 and 2007 running at the same time.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules