Ram Kumar K

Hi,
I have a html page containing some images. These images will be embedded in a .net assembly and we are using resource protocol of internet explorer to render these images from assembly. For example, the IMG tag will look like :
<img src="res://MyAssembly.dll/IMAGE/MyImage">.

When i open this html page in Internet Explorer, it shows up the images fine. But when i insert this html page in a word document, word is not showing the images which are embedded in the assembly. I want to insert this html page in a word document.

Whether Microsoft Word has support for the res protocol

Please let me know how to insert html pages with such embedded images in Word document so that Word renders images from assembly.



Thanks,
Regards,



Re: Visual Studio Tools for Office Word support for resource protocol

Cindy Meister

Indeed, Word is blissfully unaware of most things .NET-related. It does not recognize the res protocol as a valid "file path" for outside information, such as graphics or data. In order to link in pictures from an outside source, they must be saved in a "traditional" file path, either locally or in a server location.

Internally, Word will convert such a file path to an IncludePicture field. (In order to see field codes in a Word document, press Alt+F9 to toggle them.) Unless you explicitly need a dynamically linked picture in the Word result, it would probably be a good idea to unlink the field (turn it into an embedded picture). Then, once the document has been closed, you should be able to remove the picture from disk. To unlink a field (remove the field from the document, leaving what was displayed) using automation you need the Unlink method of the Field object. For example: WordRange.Fields.Unlink






Re: Visual Studio Tools for Office Word support for resource protocol

Ram Kumar Karnataka

Hi Cindy,
Thanks for the reply.
I'm currently using word automation to insert the html page containing links to assembly(.dll) for Images.
Do i have loop through all the IMG tags in the html and extract the images from the assembly and save it to the disk and refer those images in the word document and finally unlink them and then delete those images
Please correct me if i'm wrong.

Please suggest if any other feasible approaches are there.



Thanks,
Best Regards,






Re: Visual Studio Tools for Office Word support for resource protocol

Cindy Meister

Basically, yes, you will need to save all the images to disk. You don't necessarily have to rewrite the links in the HTML to correspond to the paths. An alternative method would be to insert the HTML, find those places where the images should be, then use the AddPicture method of the Shapes or InlineShapes collection to insert them.

The only other possibility that occurs to me would require Word 2003 or Word 2007 as the target version. Then you could transform the html to WordProcessingML and stream the pictures directly into that. If this sounds like something you may want to look into, the place to get futher information is OpenXMLDeveloper.org.






Re: Visual Studio Tools for Office Word support for resource protocol

Ram Kumar Karnataka

Hi Cindy,
Sorry for the delay in response.
I'm trying to extract the win32 resources from the assembly, once that is done, i think my job will become a bit easier.
Thanks for your support.
I'll get back to you incase if there is a problem while including images in word.



Best Regards,