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.
Solved! Go to Solution.
Solved by WCrihfield. Go to Solution.
Solved by Dev_rim. Go to Solution.
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
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
(Not an Autodesk Employee)
Can't find what you're looking for? Ask the community or share your knowledge.