{"id":14,"date":"2007-12-17T15:44:59","date_gmt":"2007-12-17T05:44:59","guid":{"rendered":"http:\/\/dev.plutext.org\/blog\/2007\/12\/17\/view-page-source-from-within-word-2007\/"},"modified":"2007-12-17T15:46:30","modified_gmt":"2007-12-17T05:46:30","slug":"view-page-source-from-within-word-2007","status":"publish","type":"post","link":"https:\/\/www.docx4java.org\/blog\/2007\/12\/view-page-source-from-within-word-2007\/","title":{"rendered":"&#8220;View Page Source&#8221; from within Word 2007"},"content":{"rendered":"<p>When developing software which uses WordprocessingML, you often need to look at the XML.<\/p>\n<p><a href=\"http:\/\/blogs.code-counsel.net\/Wouter\/Lists\/Posts\/Post.aspx?ID=15\">Wouter&#8217;s Package Explorer<\/a> is a great way to do this, particularly if you want to look at an existing file.<\/p>\n<p>Wouldn&#8217;t it be great (well, at least a little bit useful), if you could look at the WordML for a document from within Word?  Then you could quickly see the WordML produced when you do something in Word (format some text, create a table, add a comment etc).<\/p>\n<p>ActiveDocument.WordOpenXML provides the OpenXML corresponding to the document. plutext-client-word2007 uses this extensively in C#.<\/p>\n<p>Anyway, we can also use it in VB from within Word to open that in an Internet Explorer window, syntax highlighted and with collapsible sections (similar to IE&#8217;s default stylesheet for XML documents).<\/p>\n<p>The result:<\/p>\n<p><img decoding=\"async\" src=\"http:\/\/dev.plutext.org\/blog\/wp-content\/uploads\/2007\/12\/word2007-viewpagesource.png\" alt=\"word2007-viewpagesource.png\" \/><\/p>\n<p>The very straightforward code to do this can be cut\/pasted from <a href=\"http:\/\/dev.plutext.org\/trac\/plutext-client-word2007\/browser\/trunk\/plutext-client-word2007\/Word2007-ViewPageSource.vb\">here<\/a> -use the &#8220;download in other formats&#8221; links at the bottom of the page.  In Word, from the Developer menu &gt; Visual Basic is used to access Word 2007&#8217;s Visual Basic IDE.  You can then just paste the code into a new module.  Create or open a document, then run the VB.  That&#8217;s all there is to it.<\/p>\n<p>I specifically chose to do it using VB and not VSTO, so you don&#8217;t need Visual Studio installed to get this running.<\/p>\n<p>Also I cobbled this code together quickly, and I know it can be improved.  If you&#8217;d like me to incorporate your improvements, please feel free to send them in!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>When developing software which uses WordprocessingML, you often need to look at the XML. Wouter&#8217;s Package Explorer is a great way to do this, particularly if you want to look at an existing file. Wouldn&#8217;t it be great (well, at least a little bit useful), if you could look at the WordML for a document [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[21,22,7,14,20,12],"class_list":["post-14","post","type-post","status-publish","format-standard","hentry","category-uncategorized","tag-openxml","tag-vb","tag-word-2007","tag-wordml","tag-wordopenxml","tag-wordprocessingml"],"_links":{"self":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/14","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/comments?post=14"}],"version-history":[{"count":0,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/posts\/14\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/media?parent=14"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/categories?post=14"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.docx4java.org\/blog\/wp-json\/wp\/v2\/tags?post=14"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}