Visual Studio Development Bookmark and Share   
 index > Visual Studio Tools for Office > Template or Document code behind?
 

Template or Document code behind?

I'm creating a VSTO application that will generate documents using data stored in InfoPath forms that were posted to a SharePoint library. The idea is that someone can generate a document by going to a SharePoint list and choosing a specific document (content type) from the New menu of a library and the VSTO will query the InfoPath data that lives in a different library.

My question is, should I be creating a Word template or Word document code-behind solution?
rblitz  Thursday, October 15, 2009 3:29 PM
Hello rblitz,

Welcome to MSDN forums!

In my mind, I will suggest you create a Word template, beacuse the documents which generated by a Word document-level customization will always refer to the same customiaztion(have the save value in property  "_AssemblyLocation"  ), but a document is generated by a template won't have this problem.

If you have any further questions please feel free to ask.

Thanks.


Tim Li

MSDN Subscriber Support in Forum

If you have any feedback on our support, please contact EMAIL GONE


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Tim Li  Friday, October 16, 2009 6:37 AM

You anticipated my next question: when a user generates the new document how is it possible to share that document with users that don't have access to the vsto assembly. You're saying that this isn't a problem if I use the template approach. However, when I combine the template with the external data that I'm bringing in through some web service calls, isn't it changing the template's contents? How does it get saved to a new instance document?

Also, are there any issues with using templates in SharePoint libraries as opposed to regular documents?

Thanks for your response.

rblitz  Friday, October 16, 2009 3:31 PM

You anticipated my next question: when a user generates the new document how is it possible to share that document with users that don't have access to the vsto assembly. You're saying that this isn't a problem if I use the template approach. However, when I combine the template with the external data that I'm bringing in through some web service calls, isn't it changing the template's contents? How does it get saved to a new instance document?

Also, are there any issues with using templates in SharePoint libraries as opposed to regular documents?


I can't answer the second question, but as to the first part:

In order to share documents with users who have no access at all to the VSTO assemblies (if you'd emailed them out-of-house, for example) you'd need to remove the customization parts within the document. That's usually done using the ServerDocument part of VSTO.

When a user creates a new document from the template, any work he does in the document will not affect the template, itself. Essentially, Word creates a copy of the template, as a new document, which must be saved (the Save As dialog box will appear when the user triggers the Save command). The document maintains a link to the template which lets it use code associated with the template (and thus the web services). But the code result is written to the document, not the template.
Cindy Meister, VSTO/Word MVP
Cindy Meister  Friday, October 16, 2009 3:37 PM
Hi,

I am writing to check the status of the issue on your side. Could you please let me know if the suggestion works for you or not? If you have any questions or concerns, please feel free to let me know. I will be more than happy to be of assistance.

Tim Li

MSDN Subscriber Support in Forum

If you have any feedback on our support, please contact msdnmg@microsoft.com


Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Tim Li  2 hours 32 minutes ago

You can use google to search for other answers

Custom Search

More Threads

• ServerDocument.AddCustomization not working for Excel, Exception from HRESULT: 0x8004040A
• Previously working code breaks when VSTO2005 is installed?
• how to use ribbon control(Office 12) with C#/XAML on June CTP of WinFX
• Possible to Programmatically Discard Checkout?
• Mysterious Add-in load issue.
• Re: Select automatically a pasted Text !
• Spell Checker
• VSTO 2007 Word Addin Deployment and Installation
• Copying contacts
• do I need to serialize a class for the following scenario?