With help from the Autodesk community, I have found a solution to the posted problem.
I am posting the solution for anyone else that may need it.
1) Have your title block page number setup as a prompted entry
2) Create an external rule with the below code,
NOTE: you must add your title block name to line 41.
Sub main ()
Rename_SheetName ()
Create_PageNo()
End Sub
Function Rename_SheetName
Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
Dim oSheet As Sheet
oSheet = oDoc.ActiveSheet
Number = InputBox("Input initial number", "Rename sheets", "1")
Letter = "A"
FirstSheet=True
For Each oSheet In oDoc.Sheets
'uncomment all lines below to make the first sheet not have a letter
If FirstSheet = True
oSheet.Name = Number
FirstSheet = False
Else
oSheet.Name=Number + Letter
Letter = Chr(Asc(Letter) + 1)
End If
Next
End Function
Function Create_PageNo
Dim oDrawDoc As Inventor.DrawingDocument = ThisApplication.ActiveDocument
' Set a reference to the drawing document.
' This assumes a drawing document is active.
' Obtain a reference to the desired border defintion.
Dim oTitleBlockDef As TitleBlockDefinition
oTitleBlockDef = oDrawDoc.TitleBlockDefinitions.Item("YOUR TITLE BLOCK NAME")
Dim oSheet As Sheet
Dim oSheets As Sheets = oDrawDoc.Sheets
'oSheet = oDrawDoc.ActiveSheet
For Each oSheet In oSheets
' Check to see if the sheet already has a title block and delete it if it does.
If Not oSheet.TitleBlock Is Nothing Then
oSheet.TitleBlock.Delete()
End If
' This title block definition contains one prompted string input. An array
' must be input that contains the strings for the prompted strings.
positionOfDubbleDot = Strings.InStrRev(oSheet.Name, ":")
Length = Len(oSheet.Name)
Dim sPromptStrings(0) As String 'start counting by 0 !!!
sPromptStrings(0) = Left(oSheet.Name, Length-(Length-positionOfDubbleDot)-1) 'if there is only one promped entry
'sPromptStrings(1) = "String 2"
' Add an instance of the title block definition to the sheet.
Dim oTitleBlock As TitleBlock
oTitleBlock = oSheet.AddTitleBlock(oTitleBlockDef, , sPromptStrings)
Next
End Function
3) Run Rule to test if it works
**Optional**
I created a macro button to run the code to make the process easier,
1) go to Tools/VBA Editor
2) in the tree expand ApplicationProject(Default.ivb) and right click on the Modules folder then select insert/Module
3) Copy and paste the below code (This code is assuming the above iLogic code is in your external rules)
Public Sub Auto_Page_Numbering()
Dim addIn As ApplicationAddIn
Dim addIns As ApplicationAddIns
Set addIns = ThisApplication.ApplicationAddIns
For Each addIn In addIns
If InStr(addIn.DisplayName, "iLogic") > 0 Then
addIn.Activate
Dim iLogicAuto As Object
Set iLogicAuto = addIn.Automation
Exit For
End If
Next
Debug.Print addIn.DisplayName
Dim RuleName1 As String
EXTERNALrule = "Page Numbering" 'Name of your external iLogic code you want this macro to run
'Dim RuleName2 As String
'INTERNALrule = "Rule0"
Dim oDoc As Document
Set oDoc = ThisApplication.ActiveDocument
If oDoc Is Nothing Then
MsgBox "Missing Inventor Document"
Exit Sub
End If
'iLogicAuto.RunRule oDoc, INTERNALrule 'for internal rule
iLogicAuto.RunExternalRule oDoc, EXTERNALrule 'for external rule
End Sub
4) Rename the EXTERALrule = "Page Numbering" with your iLogic code name you want to run
5) make note of your module name (Mine is Module 3), save & Close VBA application window
6) I've attached the image I used for my macro buttons you may use them as well! place them at
C:\Users\Public\Documents\Autodesk\Inventor 2019\Macros
Rename the Images where they say "Module3" to what your module is named
7) In an Inventor drawing template right click on the ribbon/Customize User Commands...
8) where it says All Commands, Click on it and select Macros, your new button should be there.
add and hit okay
your new button should now appear on the ribbon.
Hope this helps!
the below forms were very helpful:
https://forums.autodesk.com/t5/inventor-customization/sheet-names/m-p/6827453/highlight/true#M69576
https://forums.autodesk.com/t5/inventor-forum/auto-page-numbering-1-1a-1b/m-p/8850249#M748843