none
Saving Word Document RRS feed

  • Question

  • Hi,

    I have a requirement that should allow the user to open a word document from a network folder and force the document to be saved back to that location only and prevent the user from making any local copies. I am trying to work on a solution to prevent users from making local copies. Do you think that this is even possible?

    I went ahead with the assumption that it is possible and created a VSTO Word Document application. My plan was to customize the Ribbon (using Ribbon.xml) and intercept the Save method. The problem I am facing is that the SaveOverride in the Ribbon1.cs is not firing when the user clicks Save or Save As. I've tried to put a breakpoint and also MessageBox within the SaveOverride method to no avail.

    I performed the following steps:

    STEP 1: I added the following to the ThisDocument.cs class of the word document.


            protected override Microsoft.Office.Core.IRibbonExtensibility CreateRibbonExtensibilityObject()
            {
                return new Ribbon1();
            }

     

    STEP 2: I updated the Ribbon1.xml file to the following:

    <?xml version="1.0" encoding="UTF-8"?>
    <customUI xmlns="http://schemas.microsoft.com/office/2009/07/customui" onLoad="Ribbon_Load">
      <commands> <command idMso="FileSaveAsMenu" onAction="SaveOverride"/> </commands>
      <ribbon> </ribbon>
    </customUI>

    STEP3: Added the following to Ribbon1.cs

     public void SaveOverride(Office.IRibbonControl control, ref bool convert)
     {

       //something to find out save location.

     }

    I am fairly new to VSTO and any help or suggestions would be greatly appreciated.

    Thanks,

    VK

    Sunday, July 10, 2011 5:09 AM

Answers

  • Hi VK

    The issue is probably this:

    <command idMso="FileSaveAsMenu"

    The idMso is a hardwired string value. You can find these in the control IDs download on MSDN or by hovering the mouse over the command in the Options tab for customizing the Ribbon (in the UI). I believe this one, for example, is simply "FileSaveAs"


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by VKM91 Sunday, July 10, 2011 3:53 PM
    Sunday, July 10, 2011 9:04 AM
    Moderator

All replies

  • Hi VK

    The issue is probably this:

    <command idMso="FileSaveAsMenu"

    The idMso is a hardwired string value. You can find these in the control IDs download on MSDN or by hovering the mouse over the command in the Options tab for customizing the Ribbon (in the UI). I believe this one, for example, is simply "FileSaveAs"


    Cindy Meister, VSTO/Word MVP
    • Marked as answer by VKM91 Sunday, July 10, 2011 3:53 PM
    Sunday, July 10, 2011 9:04 AM
    Moderator
  • Thanks Cindy.. that worked!!
    Sunday, July 10, 2011 3:54 PM