For Each Layout In ThisDrawing.Layouts

For Each Layout In ThisDrawing.Layouts

shastu
Advisor Advisor
1,395 Views
5 Replies
Message 1 of 6

For Each Layout In ThisDrawing.Layouts

shastu
Advisor
Advisor
I created a VBA routine within autocad using the below statement:

For Each Layout In ThisDrawing.Layouts

This loops through each layout in the current drawing. When I try to take this code into straight VB6 it gives me a Run-time error 424, Object Required. I already have the Layout defined as "Dim Layout As AcadLayout" What else do I need to get this to run?
0 Likes
1,396 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable
VB6 does not know what ThisDrawing is......


"shastu" wrote in message news:5869966@discussion.autodesk.com...
I created a VBA routine within autocad using the below statement:

For Each Layout In ThisDrawing.Layouts

This loops through each layout in the current drawing. When I try to take
this code into straight VB6 it gives me a Run-time error 424, Object
Required. I already have the Layout defined as "Dim Layout As AcadLayout"
What else do I need to get this to run?
0 Likes
Message 3 of 6

shastu
Advisor
Advisor
I realize that. That is why I am asking for help. What do I need to replace that with?
0 Likes
Message 4 of 6

shastu
Advisor
Advisor
Never mind I got it. I needed to add the following lines

Set objAcadApp = GetObject(, "AutoCAD.Application")
Set objAcadDoc = objAcadApp.ActiveDocument
objAcadApp.Visible = True

Then I changed all the "ThisDrawing" to "obcAcadDoc" and it worked.
0 Likes
Message 5 of 6

Anonymous
Not applicable
you didn't necessarily need to change your ThisDrawing declarations. you
could declared it in VB like

Dim ThisDrawing As AcadDocument

then everything works as is.


wrote in message news:5870058@discussion.autodesk.com...
Never mind I got it. I needed to add the following lines

Set objAcadApp = GetObject(, "AutoCAD.Application")
Set objAcadDoc = objAcadApp.ActiveDocument
objAcadApp.Visible = True

Then I changed all the "ThisDrawing" to "obcAcadDoc" and it worked.
0 Likes
Message 6 of 6

shastu
Advisor
Advisor
Thanks for the tip
0 Likes