Visual Basic Customization

Visual Basic Customization

Valued Contributor
Posts: 102
Registered: ‎07-23-2008
Message 1 of 2 (220 Views)

Another 64 VBA problem

220 Views, 1 Replies
09-04-2012 07:39 AM

We are beginning to purchase 64 bit computers and I am having problems with many of our legacy VBA programs.  I understand that we should convert our code to VB.Net, but for now, I need to see if I can get these older programs to work.


As I browse this discussion group, I see that I am not alone with problems in upgrading to 64 bit.


An example of one problem is shown in the sub-routine below.  It is used to change the active layout and has worked perfectly for years on our 32 bit computers.  The error occurs at ActiveDocument = DOC and the error states, "Compile Error: Invalid Use of Property"


Any help is appreciated and thanks in advance!



Public Sub GotoLayout(LayoutName As String)
 ' This will go to the layout that is specified
 Dim DOC As AcadDocument
 Dim LAY As AcadLayout
 Dim found As Boolean
 found = False
 'cycle through the layouts in the active document
 For Each LAY In ThisDrawing.Layouts
  If LAY.Name = LayoutName Then
   ThisDrawing.ActiveLayout = ThisDrawing.Layouts.Item(LayoutName)
   found = True
  End If
 'if you have not found the layout yet, then search all open drawings
 If found = False Then
  For Each DOC In Documents
   For Each LAY In DOC.Layouts
    If LAY.Name = LayoutName Then
     ActiveDocument = DOC ' <- Here is where the error occurs
     ThisDrawing.ActiveLayout = ThisDrawing.Layouts.Item(LayoutName)
     found = True
    End If
 End If
 'if you have not found the layout yet, do not continue
 If found = False Then
  MsgBox ("The " & LayoutName & " layout could not be found.")
 End If

End Sub

*Expert Elite*
Posts: 1,285
Registered: ‎06-21-2004
Message 2 of 2 (213 Views)

Re: Another 64 VBA problem

09-04-2012 11:31 AM in reply to: keithjk

Change to     DOC.Activate


(defun botsbuildbots() (botsbuildbots))
Post to the Community

Have questions about Autodesk products? Ask the community.

New Post
Do you have 60 seconds to spare? The Autodesk Community Team is revamping our site ranking system and we want your feedback! Please click here to launch the 5 question survey. As always your input is greatly appreciated.