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'.
ActivePage.Name = ActivePage.FindShape("sku").Text.Story
That's making some assumptions:
So, that line of code could work, but it would require more effort if you wanted to make it "safe".
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.
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!
Hello,See below 2 Variants without SKU. Selected text.Greetings