Visual Basic Customization

Reply
Valued Contributor
keithjk
Posts: 98
Registered: ‎07-23-2008
Message 1 of 2 (209 Views)

Another 64 VBA problem

209 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
  Next
   
 '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
   Next
  Next
 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
 End If

End Sub

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

Re: Another 64 VBA problem

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

Change to     DOC.Activate

---------------------------



(defun botsbuildbots() (botsbuildbots))

You are not logged in.

Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register

Announcements
Are you familiar with the Autodesk Expert Elites? The Expert Elite program is made up of customers that help other customers by sharing knowledge and exemplifying an engaging style of collaboration. To learn more, please visit our Expert Elite website.

Need installation help?

Start with some of our most frequented solutions to get help installing your software.

Ask the Community