Hi I am tring to change the active sheet, to sheet 1 or 2 or 3 depending on what I am doing in the code. Could someone help me with this, I do not see any example online. Remember I am working with Ilogic 2010.
I would Appreciate any help I can get. Thanks!
Solved! Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Solved by Curtis_Waguespack. Go to Solution.
Hi reddragon1964,
Here is a quick example:
'create list
'assumes your drawing has at least 3 sheets
myList = new integer(){1,2,3}
'get user input
mySheet = InputListBox("Select a sheet number.", myList, myList(0), "iLogic", "Sheet Numbers")
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim lPos As Long
Dim rPos As Long
Dim sLen As Long
Dim sSheetName As String
Dim sSheetNumber As String
For Each oSheet In oDoc.Sheets
lPos = InStr(oSheet.Name, ":")
sLen = Len(oSheet.Name)
sSheetName = Left(oSheet.Name, lPos -1)
sSheetNumber = Right(oSheet.Name, sLen -lPos )
'compare list selection to sheet number
If mySheet = sSheetNumber Then
'activate sheet
oSheet.Activate
Else
End If
Next
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
A quick update to this. This version counts the actual number of sheets in the drawing first. Then sets the sheet selected from the list to be active.
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
Dim lPos As Long
Dim rPos As Long
Dim sLen As Long
Dim sSheetName As String
Dim sSheetNumber As String
'create sheet number list
Dim oSheetList As New ArrayList
i = 0
For Each oSheet In oDoc.Sheets
i = i +1
oSheetList.add(i)
Next
'get user input
mySheet = InputListBox("Select a sheet number.", oSheetList, oSheetList(0), "iLogic", "Sheet Numbers")
For Each oSheet In oDoc.Sheets
lPos = InStr(oSheet.Name, ":")
sLen = Len(oSheet.Name)
sSheetName = Left(oSheet.Name, lPos -1)
sSheetNumber = Right(oSheet.Name, sLen -lPos )
'compare list selection to sheet number
If mySheet = sSheetNumber Then
'activate sheet
oSheet.Activate
End If
Next
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Sorry it took me so long to get back , your code worked great. I really appreciate your help and I hope I can return the favor some time.
Paul F Morrissette
Thanks Curtis,
I have learned a lot from your posts. Many thanks.
This iLogic is good, but when there is a sheet excluded from count, it doesn't work. Can you please fix this?
Regards,
This very old post, but still have question. If i create few sheets and run this rule works just perfect. I changed sheet names in browser to part number and description then i have error Argument 'Length' must be greater or equal to zero.
It would be very appreciate if somebody can help to resolve this problem so we can learn about.
Thank you
Hi @GosponZ
I think this version will work better.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
'create sheet list
Dim oSheetList As New ArrayList
For Each oSheet In oDoc.Sheets
oSheetList.Add(oSheet.Name)
Next
'get user input
mySheet = InputListBox("Select a sheet.", oSheetList, oDoc.ActiveSheet.Name, "iLogic", "Sheet names")
oDoc.Sheets.Item(mySheet).Activate
Curtis,
thank you for fast respond. I have to ask another question. Can it be done, like when activate one sheet do something and then go to another sheet etc.
Intent is to run rule to exclude from count and exclude from printing.
I'm running this rule
ActiveSheet.Sheet.ExcludeFromPrinting = True ActiveSheet.Sheet.ExcludeFromCount = True
but every time have to activate sheet in browser and then run rule. Not bad but if there is better way?
I placed those 2 lines below your code works good but i have feeling there is even faster way
Than you
Hi @GosponZ
You could use something like this to choose which sheets are excluded.
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
oCurrentsheet = oDoc.ActiveSheet
Dim oSheet As Sheet
For Each oSheet In oDoc.Sheets
oSheet.Activate
oDefault = oSheet.ExcludeFromPrinting
oExclude = InputRadioBox("Exclude from print and count?", _
"Do NOT print/count", "Do print/count", oDefault, oSheet.Name)
oSheet.ExcludeFromPrinting = oExclude
oSheet.ExcludeFromCount = oExclude
Next
oCurrentsheet.Activate
Or something like this to exclude all sheets
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oExclude = InputRadioBox("Exclude ALL from print and count?", _
"Do NOT print/count", "Do print/count", True, "iLogic")
For Each oSheet In oDoc.Sheets
oSheet.ExcludeFromPrinting = oExclude
oSheet.ExcludeFromCount = oExclude
Next
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Thank you Curtis,
it is working good but only one problem is there. It has to go thru all sheets. Can you stop rule of not running after lets say few sheets. It is not convenient if i have 70 sheets and need 5 to exclude or back to include.
You could use something like this to exclude sheets that are preselected in the browser.
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
' Get selection set
Dim oSelectSet As SelectSet
oSelectSet = oDoc.SelectSet
' If no sheets are selected, then exit
If oSelectSet.Count = 0 Then
oMsg = "You must pre select sheets in the browser before running this rule." & vbLf & _
" Hold the CTRL or SHIFT key on the keyboard too select multiple Sheets."
MessageBox.Show(oMsg, "ilogic")
Exit Sub
End If
Dim oSheet As Sheet
For Each oSheet In oSelectSet
oMsg = oMsg & oSheet.Name & ","
Next
oExclude = InputRadioBox("Select one", _
"Do NOT print/count", "Do print/count", True, oMsg)
For Each oSheet In oSelectSet
oSheet.ExcludeFromCount = oExclude
oSheet.ExcludeFromPrinting = oExclude
Next
Thank you very much Curtis. Rule is working perfect. Lot clicking saved.