How to display outline number of a topic with a macro

  • 1
  • Question
  • Updated 1 year ago

I add some outline numbers to my topics in MM17. (1. First Topic; 2. Topic; 2.1 Sub Topic...)

Now I'm trying to find out how to display the number of a topic. I know I can display the topic text of a actual selection with

    Debug.Print ActiveDocument.Selection.PrimaryTopic.Text

What is the right object? Does anyone have some example for this?

 

Photo of Thomas Muehlbauer

Thomas Muehlbauer

  • 2 Posts
  • 0 Reply Likes

Posted 1 year ago

  • 1
Photo of Nick Duffill

Nick Duffill, Champion

  • 512 Posts
  • 170 Reply Likes
Debug.Print ActiveDocument.Selection.PrimaryTopic.Title.GetDisplayText(MmDisplayTextFlags.mmDisplayTextNumberPrefix)

You can use Debug > Browse to examine the enumeration MmDisplayTextFlags for other options. Unfortunately the parameter does not seem to be shown by Intellisense in the macro editor.
Photo of Thomas Muehlbauer

Thomas Muehlbauer

  • 2 Posts
  • 0 Reply Likes
Thank you Nick, this was great. Helps me a lot
Photo of Ary Velstra, Expert Trainer

Ary Velstra, Expert Trainer

  • 1299 Posts
  • 197 Reply Likes
Just Curious...

Why is this necessary?
I use the Numbering function of Insert Tab, Topic elements. and I can show the numbers everywhere.
Photo of Nick Duffill

Nick Duffill, Champion

  • 512 Posts
  • 170 Reply Likes
Hello Ary. The numbering applied by this function does not become part of the topic text and you can't edit it together with the text. When you read the topic through the API, the text is same, whether or not the topic is numbered. You need to access a different property in the object model to find the numbering.
Photo of Ary Velstra, Expert Trainer

Ary Velstra, Expert Trainer

  • 1299 Posts
  • 197 Reply Likes
OK Nick, thanks.
Never felt the need until now, just rearranged the topics if the numbering was wrong ;-)
(Edited)
Photo of Nick Duffill

Nick Duffill, Champion

  • 512 Posts
  • 170 Reply Likes
Use Roman numerals, then nobody can tell if your numbering is right or wrong anyway :)