Wednesday, January 24, 2007

View Office 2007 documents in Office 2003

It's only been three weeks and I have already run into compatibility issues with my version of Office and some document that I would like to open from the web.  Office 2007 uses a new file format labeled the "Open XML Format". 

According to Microsoft:

"The Open XML Formats usher in a new era of openness and transparency for Word, Excel and PowerPoint. Solution developers can take advantage of a host of new integration opportunities to connect documents to important sources of information."

If you are still using Office 2003, however, you will find that the new format isn't very open or transparent to you.  Luckily, Microsoft has published a patch for Office 2003 to make it compatable with Office 2007.  You can download it here: Microsoft Office Compatibility Pack.

My only question,  if Microsoft is so gung-ho on their new format, why didn't I get this pack via Microsoft Update?

Tuesday, January 16, 2007

Fix Visio 2003 VML code for IE7 with Powershell

I have recently been tasked with providing a lot of documentation around the applications that I am working on.  I naturally turned to Visio to help me with my dataflow and physical network diagrams.  I'm using Visio 2003 and have found that this version will export your Visio file and all of its pages as a web site.  By default all of your pages will be converted into VML.  You can also insert hyperlinks into the objects on your diagram that link to other pages.

This produces a really neat web site with built in navigation and search capabilities.  It even works in FireFox, sort of.  FireFox users see a dumbed down version without the search.  I discovered my issue when I tried to use the site in IE7.  Apparently IE7 doesn't like the way the links are built.  I found more information here.  It looks like Office 2007 will fix this. 

There is a short term fix.  You just have to replace the 'href="#"' in all the vml objects to 'style="cursor:pointer;"' for each file that was generated.  In my case, I have over a dozen files.

At the bottom of the article in the comments someone mentions that there is a utility that you can down load and install to perform the fix.  But my machine is still pissed off about the last dinky utility that I installed and only use once in a blue moon.  Powershell can do this, no sweat.  Here's the line that I used.

ls vml_*.htm | % { echo $_.Name; (gc $_.FullName) -replace("href=`"#`"", "style=`"cursor:pointer;`"") | out-File $_.FullName }



First off, I'm getting all the htm files with vml code in them.  Visio conviently labels them as vml.  Then, for each file I write out the name to the console.  You don't have to have this, but I like seeing what files were processed.  The gc command reads the file into a string and the -replace command does the replacing work.  Notice that the escape character in Powershell is "`" not "\".  Finally, the original file is overwritten with the corrected string.