Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / January 2006

Tip: Looking for answers? Try searching our database.

How to get heading style number font name

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Coco - 07 Jan 2006 05:10 GMT
I would be grateful if someone could help with this before I go completely
insane. What I want to do is obtain the name of the font used for the number
in a heading style (e.g. "Heading 1").

'With this, I can get the font properties of heading style text

With ActiveDocument.Styles("heading 1")
   With .Font
       MsgBox (.Name)
       '...
   End With
End With

'With this, I can get non-font properties of heading style numbers

With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(1)
       MsgBox (.StartAt)
       '...
End With

'Using the same successful calls and syntax used in the examples above, I
can get font properties of heading style numbers except for the font name. Am
I doing something stupid here is Word known not to reveal what I seek?

With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(1)
   With .Font
       MsgBox (.Name)
       MsgBox (.Italic)
       '...
   End With
End With

Thanks.
Helmut Weber - 07 Jan 2006 11:11 GMT
Hi Coco,

hmm...

With
ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(1)
  MsgBox "[" & .Font.Name & "]"
End With

Works here and now. However, if no font was explicitly
applied to the outline characters, .font.name returns nothing.

By the way, if I format the outline characters as bold
and reset the formatting, the bold stays. ?

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Coco - 07 Jan 2006 20:55 GMT
Thanks Helmut but I think that you are referring to text on the page that has
had formatting applied to it. What I am trying to get is the font name set
for the relevant heading style number.

> Hi Coco,
>
[quoted text clipped - 10 lines]
> By the way, if I format the outline characters as bold
> and reset the formatting, the bold stays. ?
Helmut Weber - 08 Jan 2006 14:26 GMT
Hi Coco,

if there was a clear and simple method, I'd say,
somebody would have posted a solution.

However, I came about a method "selectnumber",
which works with numbered or bulleted paragraphs,
and seems not to be available from the user interface.

Selection.Paragraphs(1).SelectNumber
MsgBox Selection.Font.Name

So if there is a paragraph formatted as "heading 1",
and "heading 1" includes formatting as e.g.
ListGalleries(wdOutlineNumberGallery)...

you may get the font name, it seems.

HTH

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

Klaus Linke - 10 Jan 2006 21:59 GMT
> Selection.Paragraphs(1).SelectNumber
> MsgBox Selection.Font.Name

Ingenious! Avoiding the ListGalleries, you could also use

With Selection.Range.ListFormat
 MsgBox .ListTemplate.ListLevels(.ListLevelNumber).Font.Name
End With

... pretty byzantine code though, admittedly, compared to yours.

Regards,
Klaus
Helmut Weber - 10 Jan 2006 22:23 GMT
Hi Klaus,

>> Selection.Paragraphs(1).SelectNumber
>> MsgBox Selection.Font.Name
>
>Ingenious! Avoiding the ListGalleries, you could also use

>With Selection.Range.ListFormat
>  MsgBox .ListTemplate.ListLevels(.ListLevelNumber).Font.Name
>End With
>
>... pretty byzantine code though, admittedly, compared to yours.

I've just looked and looked around and around
and finally came across SelectNumber.
Never heard about that before.

Getting your attention and your consent means something to me.

Have a look at ...de.word
"Suchen/Ersetzen von ...",

where "mso-bidi-font" and "mso-bidi-font-size"
seem to cause trouble.

Schönen Abend noch und gut durchschlafen. ;-)

Signature

Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.