Wednesday, March 16, 2011

Programatically opening an xml file in MS Word

I'm opening an xml file in Microsoft Word 2007 using C#. I'm using an xsl file to define the layout which worked up to the point that I needed to include an image. I used the typical src html tag and the image displays when the xml is viewed in ie but not when it's opened in Word. I get the image place holder so I can only assume Word simply can't find the image. It's sitting next to both the xml file and xsl file but that doesn't make any difference. To open the document I'm passing the filenames for both the xml and xsl. I would imagine that as the src is in the xsl it would just look relative to one of these files.

Any suggestions would be much appreciated.

[EDIT] Apologies I lost track of this one. I fixed it in the end. I'll check what my solution was tomorrow and update this.

From stackoverflow
  • Did you try specifying the full URL to the file using a format like file://c/blah/blah/abc.gif ?

  • I think you need to specify the working path for the document to point at the base location. Something like this: wordDocument.Path = xml file path (or whatever that image assumes to be the base)

0 comments:

Post a Comment