Is it possible to create a macro that grabs the contents of a labelled text object and pass it onto the page name? Example below. Here I want the text object to have the label 'sku'.
What code would you use to copy selected text to a page name? My page header includes a line of text that has a sign type and a descriptor. I would like to just use the sign type to name the page. So I would like to highlight the sign type and run the code to rename the page. I'm using versions 2020 and the latest 2023.
You could use ActivePage.Index to get the number of the current page.
If you wanted to explicitly get that as a string, you could use CStr(ActivePage.Index).
You could use that string in whatever recipe you are using to come up with a new string to use as the page name.
Brute-Fish said:What code would you use to copy selected text to a page name? My page header includes a line of text that has a sign type and a descriptor. I would like to just use the sign type to name the page. So I would like to highlight the sign type and run the code to rename the page.
Quick-and-dirty, you could use this:
ActivePage.Name = ActiveShape.Text.Selection
That assumes that some range of characters are currently selected in a Text shape.
There are no safeties built into that to prevent errors (if nothing is selected, if the selection is not a text shape, etc.).
I'm on a deadline today but I will try it out next week. Thanks!
EDIT: I took a break and tried it out. Works perfectly!
Thank you Eskimo and Brute. I will try this.