ASP/VB: Word Doc file generation
Posted on 2004-08-23
We use the Word.Application component to convert our HTML report files into Word DOC files. This works good. But this process is inefficient, in that for generating every word document, we have to load the resource intensive Word.Application component every time and there is a known issue of some reports failing when a lot of our customers try to generate word reports at the same time.
We have looked at using some substitute components to perform this translation (SoftArtisans WordWriter, but the integration is not seamless enough and we need this done very quickly). Now, to solve this issue, I am trying to use the Response.ContentType statement to transform the HTML output, and then save the resulting output as a ".doc" file.
Here're the statements:
Response.AddHeader "Content-Disposition", "attachment; filename=reportName.doc"
Response.Charset = "UTF-8"
Response.ContentType = "application/msword"
This works too! But not quite good enough.
The problem is that this removes the control over the format of the word file that I normally get when using the Word.Application component. Main problem is that the images in the word document are now linked to the images on the server:
1. Is it possible to set the Word DOC properties like
SavePictureWithDocument = True
ActiveDocument.ActiveWindow.View.Type = wdPrintView
etc., using ASP?
2. Is there another way to do this; ie, altering the normal.doc template file on the server where these files are being saved, so that the image links are broken.