none
Referencing style "Placeholder Text" in an international Add-In RRS feed

  • Question

  • Hi all,

    due to some building blocks the placeholder style appears in the styles-box.

    I'd like to hide the style in the box (styles("Placeholder Text").visibility = true) via VBA: But how do I reference the PlaceholderText-Style without using a local name? E.g. in Germin the style is called "Platzhaltertext", in English "Placeholder Text", in French ???

    I already studied the wdBuiltInStyle Consts - but nothing seems to fit.


    Ingrid
    • Edited by I.Kellerer Thursday, February 14, 2013 4:52 PM
    Thursday, February 14, 2013 4:52 PM

Answers

  • Unfortunately, not all built-in styles have a corresponding wdBuiltinStyle constant (another example is the Balloon Text style). You will have to add a test that searches for different language versions of the Placeholder Text style and set the visibility for the style name found in the particular document.

    Stefan Blom, Microsoft Word MVP
    • Marked as answer by I.Kellerer Thursday, February 14, 2013 7:47 PM
    • Edited by Stefan BlomMVP Thursday, February 14, 2013 8:03 PM (added clarification)
    Thursday, February 14, 2013 7:39 PM

All replies

  • Unfortunately, not all built-in styles have a corresponding wdBuiltinStyle constant (another example is the Balloon Text style). You will have to add a test that searches for different language versions of the Placeholder Text style and set the visibility for the style name found in the particular document.

    Stefan Blom, Microsoft Word MVP
    • Marked as answer by I.Kellerer Thursday, February 14, 2013 7:47 PM
    • Edited by Stefan BlomMVP Thursday, February 14, 2013 8:03 PM (added clarification)
    Thursday, February 14, 2013 7:39 PM
  • Hi Stefan,

    I was afraid to get this answer :-(

    Nevertheless - thanks!

    Thursday, February 14, 2013 7:47 PM
  • Just out of interest, does the constant 196 work in the German version? This may be one of those situations where some styles have had constants assigned, but have not had a named constant assigned.

    Peter Jamieson

    Friday, February 15, 2013 6:18 PM
  • Wow - it's not 196 but -157.

    wdBuiltInStyle-Constants are negative: So I did a "For i = -200 to -1" and - hurra - thisworkbook.styles(-157).namelocal returns "Platzhaltertext"

    Maybe someone can check that with a different language than German.

    Friday, February 15, 2013 7:08 PM
  • Just out of interest, does the constant 196 work in the German version? This may be one of those situations where some styles have had constants assigned, but have not had a named constant assigned.

    Peter Jamieson




    That's interesting. Thank you. (Now, if I was running a Swedish version of Office, I'd test the constant in that version.)

    Stefan Blom, Microsoft Word MVP

    Friday, February 15, 2013 7:18 PM
  • I should have said 197 :-) That seems to work on the English language version of Word 2010. So does -157. However, I also looked on Mac Word 2011, where the English language version equivalents are 206 and -166, and the Dutch language version ("Tekst van tijdlelijke aanduiding") uses 260 (not 206) and -166. So the numbers are certainly not reliable cross-platform, and of course there is always a risk that an undocumented value will not be reliable long-term or across all locales on Windows.



    Peter Jamieson

    Saturday, February 16, 2013 1:33 AM
  • I should have said 197 :-) That seems to work on the English language version of Word 2010. So does -157. However, I also looked on Mac Word 2011, where the English language version equivalents are 206 and -166, and the Dutch language version ("Tekst van tijdlelijke aanduiding") uses 260 (not 206) and -166. So the numbers are certainly not reliable cross-platform, and of course there is always a risk that an undocumented value will not be reliable long-term or across all locales on Windows.


    Peter Jamieson




    It seems rather unreliable then. I guess that brings us back to square one...

    Stefan Blom, Microsoft Word MVP

    Saturday, February 16, 2013 7:06 PM
  • Not really: you could of course claim that the OP faces greater uncertainty (previously, they only had one way to go other than "we won't attempt to hide the style"). But i think the OP has a choice, depending on how reliably they need this part of their s/w to work and how much effort they would have to put in to discover the style names for all the locales they need to support. they could for example choose to code for "known" locales using the style name, but use a catch-all -157 for everything else, at least until someone reports a problem. As for Mac portability, that can be whole different story anyway.

    Peter Jamieson

    Sunday, February 17, 2013 9:02 AM
  • Hi Peter,

    I think I will solve it the way you described it. In the end it's not a showstopper, and the users know whom to contact. But still it's another annoying story of the diva "content controls".

    Ingrid

    Sunday, February 17, 2013 9:21 AM
  • Not really: you could of course claim that the OP faces greater uncertainty (previously, they only had one way to go other than "we won't attempt to hide the style"). But i think the OP has a choice, depending on how reliably they need this part of their s/w to work and how much effort they would have to put in to discover the style names for all the locales they need to support. they could for example choose to code for "known" locales using the style name, but use a catch-all -157 for everything else, at least until someone reports a problem. As for Mac portability, that can be whole different story anyway.

    Peter Jamieson




    I have to admit I was thinking of the uncertainty you mention (and the complexity), but you make a good point.

    Stefan Blom, Microsoft Word MVP

    Sunday, February 17, 2013 2:54 PM