none
Disappearing content RRS feed

  • Question

  • Using Word 2007, in a text box, I insert the contents of a file using Insert | Object | Text from File.  The file I am inserting is an XML file.

    My first reaction  - it failed to insert. However, it did succeed BUT I cannot see the contents until I click on the button to change the colour of the text box content: what appears is nicely formatted using graphical shapes. Print Preview does not show the graphics either.

    How do I display the XML file graphics in the text box permanently?

     

    Thanks.




    Tuesday, April 26, 2011 11:23 AM

Answers

All replies

  • I figured out how to display the XML permanently:

        ActiveWindow.View.ShowXMLMarkup = wdToggle

    Remaining question: how do I print (or save as PDF) with the XML markup showing/visible?

     

    Tuesday, April 26, 2011 1:12 PM
  • I figured out the answer to my last question:

     

     Options.PrintXMLTag = True

    Tuesday, April 26, 2011 1:15 PM
  • Hi Aask

    Just a bit of information about the functionality you're building on:

    Microsoft lost a court decision a couple of years ago and has had to remove the "XML Markup" functionality from Word. So what you're doing may not work in future versions. It might be good to know that before you invest too much in the approach you're working on :-)


    Cindy Meister, VSTO/Word MVP
    Tuesday, April 26, 2011 4:58 PM
    Moderator
  • Cindy, thanks for pointing this out.

    If I understand correctly, what I am doing is possible in Word 2007 but not in Word 2010. Am I correct?

    If yes, what will happen when I will open my Word 2007 saved document in Word 2010? I mean to the display of the document - I guess the VBA will not work.

    Tuesday, April 26, 2011 7:34 PM
  • Hi Aask

    If you open a document that has XML tags in Word 2010, those tags will be removed from the document. (Note that the same can happen in some versions of Word 2007. any Word 2007 sold in North America after January 1 2010 will also not have the capability.)

    Word 2010 can still create tags in an already opened document, but once it's closed and re-opened the tags will be gone.

    The version of Word after that probably won't even be able to create tags, anymore.

    The recommended alternate approach is to use content controls as "placeholders". As content controls don't have all the same functionality as XML tags, this may or may not be a feasible workaround for you.


    Cindy Meister, VSTO/Word MVP
    Wednesday, April 27, 2011 12:50 PM
    Moderator