none
Document-Level Customization Template and Document (not vs) RRS feed

  • Question

  • We have one Template-Level customization to allow users to create their own version of a template which they store seperately (they might have several of those). Then we would also need to offer them some operations which they can execute within the generated document. 

    From my understanding, this would mean having a template based customization to generate the word document based on a word template and then having a document based customization. Can this be achieved at all? What would be the steps to have a combination of the two customizations? Or is an add-in the only way to achieve something like this? Or can a document level customization be built on top of a dotx? So that first the docx will be created from the dotx and then the customization will work on the docx?

    Marc

    Sunday, February 16, 2014 1:14 AM

Answers

  • Hi Marc,

    >> From my understanding, this would mean having a template based customization to generate the word document based on a word template and then having a document based customization. Can this be achieved at all? <<

    Document Level Add-In is an independent part, the customization in template (*.dotx) document will not be applied to *.docx document. But it is possible to attach document customization programmatically. For more details (refer to How to: Attach Managed Code Extensions to Documents).

    string documentPath = System.Environment.GetFolderPath(
        Environment.SpecialFolder.Desktop) + @"\WordDocument1.docx";
    int runtimeVersion = 0;
    
    try
    {
        runtimeVersion = ServerDocument.GetCustomizationVersion(documentPath);
    
        // Make sure that this document does not yet have any Visual Studio Tools  
        // for Office customizations. 
        if (runtimeVersion == 0)
        {
            string deployManifestPath = System.Environment.GetFolderPath(
                Environment.SpecialFolder.Desktop) + @"\Publish\WordDocument1.vsto";
    
            Uri deploymentManifestUri = new Uri(deployManifestPath);
            ServerDocument.AddCustomization(documentPath, deploymentManifestUri);
            System.Windows.Forms.MessageBox.Show("The document was successfully customized.");
        }
        else
        {
            System.Windows.Forms.MessageBox.Show("The document is already customized.");
        }
    }
    catch (FileNotFoundException)
    {
        System.Windows.Forms.MessageBox.Show("The specified document does not exist.");
    }
    catch (DocumentNotCustomizedException ex)
    {
        System.Windows.Forms.MessageBox.Show("The document could not be customized.\n" +
        

    About more information about Office Document Level customization, please refer to articles below:

    Architecture of Document-Level Customizations

    Programming Document-Level Customizations


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, February 17, 2014 9:22 AM
    Moderator