VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Another 64 VBA problem

1 REPLY 1
Reply
Message 1 of 2
keithjk
381 Views, 1 Reply

Another 64 VBA problem

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

1 REPLY 1
Message 2 of 2
arcticad
in reply to: keithjk

Change to     DOC.Activate

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



(defun botsbuildbots() (botsbuildbots))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost