Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to switch between tabs?

2 REPLIES 2
SOLVED
Reply
Message 1 of 3
Hubert_Los
391 Views, 2 Replies

How to switch between tabs?

Hello,

How to switch between tabs? Ideally, I would like to be able to change tabs using the ID number
Unfortunately, I can't use "thisApp.Documents.VisibleDocuments.Item(ID)" because I don't know the order in which the files are opened.

Alternatively, how to pause the program by selecting the appropriate tab, and then resume the program.

 

Hubert_Los_0-1680011210088.png

 

2 REPLIES 2
Message 2 of 3
Dev_rim
in reply to: Hubert_Los

Hi Hubert,

You can get all visible documents as a DocumentsEnumerator with that code:

 

 

Dim invApp As Application
Set invApp = ThisApplication
Dim docs As DocumentsEnumerator
Set docs =invApp.Documents.VisibleDocuments

 

 

I can't understand what did you mean by ID but, if you are talking about indexes, indexes starting from 1 so if you use 0 you will get an error.

This is activating the second tab from left

 

 

 

Dim invApp As Application
Set invApp = ThisApplication
Dim docs As DocumentsEnumerator
Set docs = invApp.Documents.VisibleDocuments
Call docs.Item(2).Activate()

 

 

 

If you want to filter that thing (like the thing you defined as ID lets say)

You can activate the tab you need like this:

 

 

 

Dim invApp As Application
Set invApp = ThisApplication
Dim docs As DocumentsEnumerator
Set docs = invApp.Documents.VisibleDocuments
Dim doc As Document
For Each doc In docs
    If '' put your condition here
        Call doc.Activate
        Exit For
    End If
Next

 

 

 

You did not mention anything so I wrote them on VBA.

 

I hope it helps

Regards

Devrim

 

If my answer is solved your problem, please mark it as Solution

Freundliche Grüße / Kind Regards
Message 3 of 3
WCrihfield
in reply to: Hubert_Los

I agree with the previous response...the 'visible' documents is generally the best way to navigate which tab you want to be 'active', because the Document object has the 'Activate' method.

FYI:  Another way to access those tabs is by Application.Views (ThisApplication.Views).  The 'Caption' of the View is what you see in the tab, which is usually the display name of the document.  The View also has an 'Activate' method.  There is also a document associated with each View.  They are generally in the natural order that they were first created.  But the only ways to loop through them is by either 'For Each' or by their 'Index' Integer, not by their name.

Dim oViews As ViewsEnumerator = ThisApplication.Views
For Each oView As Inventor.View In oViews
	MsgBox("oView.Caption = " & oView.Caption)
	'Dim oViewDoc As Document = oView.Document
Next

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

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

Post to forums  

Autodesk Design & Make Report