John McAllister

Hi,

I have been doing some research recently into VSTO as I have a project that may require it. So far I have not found any help out there on the following:

I have various Word documents that are letters that will need to be sent out to customers. I would like these "templates" to be personalised using a Web front-end. So basically the member of staff takes information over the phone from the customer and inserts it into a web-form. The web-form then produces a pre-populated Word letter document.

Is this possible using VSTO I think I could create a multi-project as this needs to be an intranet solution (I know Microsoft don't recommend this over the internet) - a website and add a Word project to this. I have tried this, and have inserted fields into a Word document, but when I programmatically open the Word document, the content of the fields are not displayed. I would like to be able to reference these fields in code in the web project in order to populate them from the web form.

Is this possible and is it the best solution Any help is greatly appreciated. I have done this using classic ASP where I placed ASP variables in the document and convert it to a text file, then open the text file in Word and the document is prepopulated from the web form.

Thanks in advance,

John


Re: Visual Studio Tools for Office Using a Multi-Project with a Web Site frontend and VSTO Word Project to populate Word templates

Cindy Meister

Hi John

VSTO is more targeted at giving the user support when he's creating a particular type of document. For your scenario (and I'm assuming Office 2003 or later since you're considering VSTO) I'd say the better approach would be to work with Word's XML file format. Create the basic document ("template") and save it as XML. Your web app can then use standard XML tools to put the information into the "fields" (transform). No need to have Word installed, or to automate it.

For the fields you could use just about anything (bookmarks, some kind of Word field, placeholder text), but attaching the document to a schema and inserting XML fields from the schema would be "simplest" as you could easily write the transform to work only with fields from your own (the schema's) namespace.

Word 2003 and 2007 can open the WordProcessingML file format. The Word 2007 file format (OpenXML - see OpenXMLDeveloper.org for more information) can be opened by Word 2000 and later if the Compatibility Pack for the Office 2007 file formats has been installed. If the user has automatic updates, then he gets that automatically for 2002 and 2003. Otherwise it's a converter download on the MSFT site.

Futher thought RE VSTO: It would be possible for you to set up a VSTO document, with Bookmark controls and data-bindings. The ServerDocument functionality should let you fill the data. And then remove the document-level customizations so that "everyone" can open the document without needing VSTO. See for example

http://msdn2.microsoft.com/en-us/library/h7eb01hx(VS.80).aspx

http://msdn2.microsoft.com/en-us/library/8fza57cs(VS.80).aspx

Personally, I just find the XML approach less complex, and you don't need to have the VSTO stuff installed anywhere.






Re: Visual Studio Tools for Office Using a Multi-Project with a Web Site frontend and VSTO Word Project to populate Word templates

John McAllister

Many thanks for your helpful response Cindy. I have not worked with XML before - do you know of any helpful resources on MSDN that I could use in order to work with populating a Word document from a web form using XML

Many thanks,

John




Re: Visual Studio Tools for Office Using a Multi-Project with a Web Site frontend and VSTO Word Project to populate Word templates

Cindy Meister

Not so much on msdn as at OpenXMLDeveloper.org, although that's targeted more at 2007. But the internal XML that defines the Word document is pretty much the same (WordProcessingML) in both versions.

The best resource I know of, besides the Word 2003 schemas (which you should find for download on msdn) is the O'Reilly book "Office 2003 XML". That goes into quite some detail about how WordProcessingML is structured, what to expect of it, and how to effectively transform it.