VBA_ font name "+mj-lt"

  • Thread starter Thread starter Edward
  • Start date Start date
E

Edward

Hi every one,
I use .Font.name="+mj-lt" to apply heading and body text font , but later
when I check the same font using

If .Font.Name = "+mj-lt" Then
some code
Else
debug.print .font.name
End If
it can't recognize the heading font although it prints the same name and in
fact its the same font.
Any thoughts?
 
Hello Edward,
I haven't understood your question completely.

You can use +mj-lt to set the font name but "+mn-lt" are just representations
that PowerPoint stores internal. When you query the font name it will always
return the name of the actual font used.

So If .Font.Name = "+mj-lt" check will always fail.

Regards,
Shyam Pillai

Handout Wizard : http://skp.mvps.org/how
 
Thanks. You answered my question by saying " If .Font.Name = "+mj-lt" check
will always fail " , but it seems if we can’t make that comparison then at
least from dynamic programming perspective it defeats the purpose of using
“+mj-ltâ€. I my addin I use “+mj-lt†to set font and this is very helpful
feature when users change the font theme all the fonts automatically change,
and I don't need to change the code and use a new font name in my code ( this
is especially useful because in our company we have mutiple regions with
diffrent font themes .
I have a function in my addin which checks all the fonts in the presentation
and if they are not heading or bodytext fonts (font theme) then changes them
to either one based on some rules . Now if I have to use actuall font names
"If .Font.Name = "Arial" "for comparison instead of " If .Font.Name =
"+mj-lt" " then everytime there is a font theme change i need to change my
code and even worse I have to check each region in my code and apply a
diffrent font .
 
Edward,
Don't hardcode font names. Compare the font name against the name of the
theme font, that will work for your specific need.

Check whether Object.Font.Name =
ActivePresentation.Designs(1).SlideMaster.Theme.ThemeFontScheme.MajorFont(msoThemeLatin)

Regards
Shyam Pillai

Handout Wizard: http://skp.mvps.org/how
 
Back
Top