Programmtically show / hide xml tags in the document

Hi,

I was wondering if it is possible to programmatically set the "Show XML tags in the document" option in the XML Structure task pane.

Joel



Answer this question

Programmtically show / hide xml tags in the document

  • jcampana

    Worked like a charm!

    Thanks Cindy.

    I do still have one question though, but it's more for curiosity sake than anything else. Why is the ShowXMLMarkup property an Integer Not only that, why is -1 true and 0 false Every other property that gets set using a checkbox is a boolean. True means checked, false means not checked. It only makes sense.

    Anyways, thanks again Cindy,

    Joel


  • WillemM

    In Word, often (not always) the macro recorder is your friend. Start the recorder, perform the steps, then check (in the New Macros module of the VB Editor) what comes out. In this case:

    ActiveWindow.View.ShowXMLMarkup

    So, you need the ShowXMLMarkup property, of the View object/property of a Window object (it need not be ActiveWindow, per se, just any Word Window object related to the document in question)



  • denesh

    Hi Joel

    Well, you're dealing with a COM object model that was designed to work with a VB language. Technically, these always use integers for "true/false". False is always 0; true could be 1 or -1 (depending on how old the app is). In the case of this property (as with quite a few others in Word), it also accepts a value of "wdToggle" which has the value 9999998 (&H98967E), so you're forced to use an int value.

    I've never inquired as to why the team that developed Word VBA included this :-) But the macro recorder does use it when it perceives the user is doing something that's on/off. I suppose the basic theory is that most people can figure out they need to write true or false if they want to force something, but "the average Joe" won't twig as to how to write xyz = !xyz



  • Programmtically show / hide xml tags in the document