iLogic change sheet name with parameters

iLogic change sheet name with parameters

Anonymous
Not applicable
1,034 Views
4 Replies
Message 1 of 5

iLogic change sheet name with parameters

Anonymous
Not applicable

Hello,

I changed the names of the sheets to part numbers using the rules posted on the forum.Now I would like to add extra text "NOT PRINT" to name in selected sheets using the assembly parameters. I can not write a code that reads the existing name of the sheet. Where do I make a mistake? I will be grateful for your help.

 

 

Dim oDoc As DrawingDocument
oDoc = ThisApplication.ActiveDocument
oSheets=ThisDrawing.Document.Sheets

Dim oSheet As Sheet
Dim sSheetName As String


If Parameter("assemble.iam.item1") = False Then
oSheets.Item(30).Activate
mSheetName = oSheet.Name

ActiveSheet.Sheet.Name = mSheetName & "NOT PRINT"
	
Else
'do nothing
End If


If Parameter("assemble.iam.item2") = False Then
oSheets.Item(31).Activate
mSheetName = oSheet.Name

ActiveSheet.Sheet.Name = mSheetName & "NOT PRINT"
	
Else
'do nothing
End If

0 Likes
Accepted solutions (1)
1,035 Views
4 Replies
Replies (4)
Message 2 of 5

Owner2229
Advisor
Advisor

Here you go:

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheets As Sheets = ThisDrawing.Document.Sheets

Dim Surfix As String = "NOT PRINT"

If Parameter("assemble.iam.item1") = False Then
    Dim oSheet As Sheet = oSheets.Item(30)
    oSheet.Activate()
    oSheet.Name = oSheet.Name & Surfix
Else
    'Do nothing
End If

If Parameter("assemble.iam.item2") = False Then
    Dim oSheet As Sheet = oSheets.Item(31)
    oSheet.Activate()
    oSheet.Name = oSheet.Name & Surfix
Else
    'Do nothing
End If
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 3 of 5

Anonymous
Not applicable

Thank you for a quick answer but the code does not work properly. The rule activates sheet but does not add surfix 😞

0 Likes
Message 4 of 5

Owner2229
Advisor
Advisor
Accepted solution

Alright, I've done some testing and here's the correction (orange):

 

Dim oDoc As DrawingDocument = ThisApplication.ActiveDocument
Dim oSheets As Sheets = ThisDrawing.Document.Sheets

Dim Surfix As String = "NOT PRINT"

If Parameter("assemble.iam.item1") = False Then
    Dim oSheet As Sheet = oSheets.Item(30)
    oSheet.Activate()
    Dim FNP As Integer = InStrRev(oSheet.Name, ":", -1)
    oSheet.Name = Left(oSheet.Name, FNP - 1) & Surfix
Else
    'Do nothing
End If

If Parameter("assemble.iam.item2") = False Then
    Dim oSheet As Sheet = oSheets.Item(31)
    oSheet.Activate()
    Dim FNP As Integer = InStrRev(oSheet.Name, ":", -1)
    oSheet.Name = Left(oSheet.Name, FNP - 1) & Surfix
Else
    'Do nothing
End If
Consider using "Accept as Solution" / "Kudos" if you find this helpful.
- - - - - - - - - - - - - - -
Regards,
Mike

"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - John F. Woods
0 Likes
Message 5 of 5

Anonymous
Not applicable

Now works perfectly.

Thank you very much! 

0 Likes