Wrap VSTO Projects in other Projects?

I am looking for suggestions or direction on a project. I have come across a couple of samples that relate to Office Projects that I want to wrap inside of a large VS.Net project. My problem is this, from what I can see, Office Projects connect to one document each, but in my case I have one dataset that feeds and builds 8-12 different document templates.

I am using the WordReadWriteadoVB Sample as my framework, but need to be able to use several document templates with the same codebase.

Any Suggestions or other places I can look for docs

Thanks;

Daivd




Answer this question

Wrap VSTO Projects in other Projects?

  • kvieceli


    You may want to build a tiny tool that executes the AddCustomization method for each additional Template right after you built the new version of your Customization .dll in the VSTO project to get the other templates updated with this new version.

    -= Maarten =-



  • nou2006

    David,

    When you create a VSTO customization you basically end up having an Office (Word/Excel) document and the customization assembly. The Office document contains the internal customization information required to load the customization asembly the next time you open it.

    Now, what can you do when you want to re-use the logic in your customization assembly in a different Office document Well, you use the ServerDocument.AddCustomization. What this method allows you to do is taking a VSTO customization assembly and attach it to a Word/Excel document (just in case, you can attach a VSTO Excel customization to an Excel workbook and a VSTO Word customization to a Word document). And by attaching I mean adding to your document the internal customization information required to load your customization assembly.

    The parameters for the ServerDocument.AddCustomization method are:

    string documentPath : the path to the Word/Excel document you want to customize

    string assemblyName: the path to your customization assembly

    string deploymentManifestPath: this can be null or empty if you are not using a deployment manifest.

    string applicationVersion: this is whatever version number you want to assign to your application.

    bool makePathsRelative: sets whether the assembly location information is saved in the document as a relative path to the document path or as an absolute path.

    If you develop a newer version of your customization AND you want your old/existing customized documents to use this newer version, you will need to use ServerDocument, first to Remove the old customization and then to attach the new one.

    I hope this helps,

    Daniel



  • Brunni

    I just across this in the code in the sample,

    Public Sub _Startup(ByVal application As Object, ByVal document As Object)

    ThisApplication = CType(application, Word.Application)

    ThisDocument = CType(document, Word.Document)

    If (ThisDocument.FormsDesign = True) Then

    ThisDocument.ToggleFormsDesign()

    If (ThisDocument.Path <> "") Then

    ThisDocument_Open()

    End If

    End If

    End Sub


    Would it make sense that when I am instantiating the method, to pass it the name of the template document to use Shouldn't I be able to just call a new _Startup("Word", "TemplateX") and load the different template versions

    Does that make sense

    DE



  • lucho16209

    Ok, I see where this goes. It just seems there should be a better way to doit that adding data to the template via the manifest that binds it to the library.

    I guess what I will have to do is add a couple of methods to the overall application to add and remove the templates from the application, so as either code or templates are updated they can be relinked.

    That is right

    Thanks again!

    David



  • bpsmicro

    The example I mentioned above is from a Word VSTO Article, not Office Automation.

    Ok, so I am reading through Marteen's referenced document and I am trying to understand what it does. This code actually makes changes to the Document Template adding code to it And it is tied to a specific software version via the application version number

    So with each update to our software, we would need to re-attach the templates to the app

    Thanks for your feedback,

    David



  • Stephen B


    David, in fact it is the other way around. If you developed a Word VSTO project customization is added to the output Template or Document file. The customization is held in the .dll that you can find in the 'debug' or 'release' output directory. In this directory you also can find the Template or Document file that is 'customized' with this .dll.

    What I understand from the information you previously provided is that you have multiple Templates that you wanted to give the same behavior as the one in your Word project.

    With the AddCustomization method as pointed out in the link I provided, you are able to 'attach' the customization .dll to all other templates that you would like to give the same application logic.

    Hope it helped,

    -= Maarten =-

    Hmm, Daniel posted an answer a few minutes before my answer ;-)



  • rahamath

    DEWright_CA,

    By taking a look at the code sample you are refering to, it seems that you are not using VSTO to develop your application but only automating Office from C# using the PIAs. In that case I would suggest to post your question to the Excel development newsgroup:

    · General programming issues: excel.programming newsgroup

    http://msdn.microsoft.com/newsgroups/default.aspx dg=microsoft.public.excel.programming&lang=en&cr=US

    If you are using VSTO then Marteen suggestion of using the ServerDocument.AddCustomization functionality is probably the best approach. It would allow you to develop a single VSTO customization and then attach it to as many templates as you need.



  • Tim Thornton

    That makes sense, but where I am going is that the client will be delivered 4-5 templates and a document that shows them what they need to do to create new templates. So they will create a new template in Word adding the appropriate XML tags, but when finished will have to register that doc in the App, so I think when that happens I will also trigged the function to add the manifest data for the assembly.

    Does that make sense

    DW



  • jonbu

    One thing that comes to my mind is that you could add the newly built customization to the other document templates using the ServerDocument.AddCustomization method. To do that you have to create a small utility that you can run in your build process.

    Here is a link to the AddCustomization documentation on MSDN: http://msdn2.microsoft.com/en-us/library/ms185673.aspx

    -= Maarten =-



  • Wrap VSTO Projects in other Projects?