Results 1 to 9 of 9
  1. #1
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    York, Pennsylvania, USA
    Posts
    164
    Thanks
    0
    Thanked 3 Times in 2 Posts
    Is there a way in Word 2007 to prevent a user from changing the open document name during a SaveAs?

    Thanks

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    [quote name='mdenison' post='791984' date='03-Sep-2009 10:44']Is there a way in Word 2007 to prevent a user from changing the open document name during a SaveAs?

    Thanks[/quote]
    First thing that comes to mind is to ask: why do you want to do that? - the purpose of the SaveAs dialog is to allow the user to save the open document as a new document, with a different name. If you use the SaveAs dialog, but keep the document name the same, then that is the same thing as doing a Save, in which case, why even show the SaveAs dialog?

    If you want to prevent users from using SaveAs, it might be better to disable/repurpose the command altogether, rather than let users open the SaveAs dialog at all. But this seems quite excessive - for one thing, the user could still get around this constraint by renaming or copying the document outside of Word altogether.

    Another question: do you want to absolutely prevent users from saving the document with a new name in Word, or would a warning (say, before the dialog appears) suffice?
    What's the background behind the need for clamping down on SaveAs this way?

    Gary

  3. #3
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    York, Pennsylvania, USA
    Posts
    164
    Thanks
    0
    Thanked 3 Times in 2 Posts
    I've developed an application which pulls information into a document, then saves it into a network location. The user's supervisor reviews the document, then when approved, moves the document into an 'Approved' folder. These documents are 'reports' done for insurance claims. When the next 'report' on the claim transpires, the user can pick the documents which apply to the specific claim numberfor the 'Approved' directory, using documents displayed where the saved named is a concatenation of the claim number, report type and sequential number corresponding to the last report done. This name is computed by my program and the logic needs to be geared around the above document name. The selected document is automatically generated, then saved with the next sequence number in the document name. Which again goes through an approval cycle. Needless to say, some users decide to use their own naming convention which breaks the logic for opening the latest document in the series.

    We have sufficient read/write authority on the various folders that ensure the documentation is secured, per insurance regulations.

    As you said, the easiest way is to create as SaveAs sub containing nothing but a message for the user.

    I haven't found a way to do this in Word 2007, unfortunately.

  4. #4
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='mdenison' post='792015' date='03-Sep-2009 12:45']As you said, the easiest way is to create as SaveAs sub containing nothing but a message for the user.[/quote]
    I assume you have tried the full "command" name FileSaveAs as the name of your "hijack" procedure. There also are some events you could monitor if Word 2007 is ignoring the old ways.

    As for the function of the procedure, do you need anything from the user at all? For example, if you need a folder, you could use a different dialog or you could avoid executing the dialog and extract the information from the user's file name.

  5. #5
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    York, Pennsylvania, USA
    Posts
    164
    Thanks
    0
    Thanked 3 Times in 2 Posts
    I tried the FileSaveAs and that fails to intercept the 2007 user input. Recording a macro didn't work as well - that just adds code for the dialog box.

    We need nothing from the user to initially save the document, since it's saved to the correct folder with the correct name.

    Word 2007 is certainly a different animal then prior versions. I've found web references to modifying the ribbon to removed the 'Save As' section, but this doesn't sound too straightforward, nor necessary, hopefully.

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    [quote name='mdenison' post='792523' date='08-Sep-2009 09:45']I tried the FileSaveAs and that fails to intercept the 2007 user input. Recording a macro didn't work as well - that just adds code for the dialog box.

    We need nothing from the user to initially save the document, since it's saved to the correct folder with the correct name.

    Word 2007 is certainly a different animal then prior versions. I've found web references to modifying the ribbon to removed the 'Save As' section, but this doesn't sound too straightforward, nor necessary, hopefully.[/quote]
    FileSaveAs does work, but only if the user clicks on the left side of the split control. (The new SaveAs is a split control - click on the left side, and you get the straight SaveAs command, click on the arrow on the right side, and you get the expanded SaveAs Menu, with additional options for SaveAs file types.)
    The good news is that there appears to be a command for every item in the expanded SaveAs Menu, the bad news is that a lot of these don't appear to work when used via VBA.
    So for instance:
    Code:
    Sub FileSaveAs()
       MsgBox "Intercepted FileSaveAs"
    End Sub
    works to intercept clicking the left side of the split SaveAs control.

    And the following two work to intercept specific items in the expanded SaveAs Menu:
    Code:
    Sub FileSaveAsOtherFormats()
       MsgBox "Intercepted FileSaveAsOtherFormats"
    End Sub
    
    Sub AdvertisePublishAs()
       MsgBox "Intercepted AdvertisePublishAs"
    End Sub
    BUT, the following should work, but appear not to:
    Code:
    Sub FileSaveAsWordDocx()
       MsgBox "Intercepted FileSaveAsWordDocx"
    End Sub
    
    Sub FileSaveAsWordDotx()
       MsgBox "Intercepted FileSaveAsWordDotx"
    End Sub
    
    Sub FileSaveAsWord97_2003()
       MsgBox "Intercepted FileSaveAsWord97_2003"
    End Sub
    This may just be a bad/faulty implementation of VBA for these new 2007 commands...
    Gary

  7. #7
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts
    Addendum:
    There's one other command available, that looks like it should work: FileSaveAsMenu. You would think intercepting this command would capture the user clicking on the right arrow of the split SaveAs control.
    But the following does nothing:
    Code:
    Sub FileSaveAsMenu()
       MsgBox "Intercepted FileSaveAsMenu"
    End Sub
    Gary

  8. #8
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts
    [quote name='mdenison' post='792523' date='08-Sep-2009 06:45']I tried the FileSaveAs and that fails to intercept the 2007 user input.[/quote]
    The documentation for application-level events is a little disjointed, but here is the official MSDN page -- DocumentBeforeSave Event [Word 2007 Developer Reference] -- and you can dredge up numerous examples from the Lounge and elsewhere for pre-2007 Word. Not sure if they have changed anything fundamental.

  9. #9
    2 Star Lounger
    Join Date
    Jun 2001
    Location
    York, Pennsylvania, USA
    Posts
    164
    Thanks
    0
    Thanked 3 Times in 2 Posts
    Thanks again, folks. The DocumentBeforeSave event does exactly what I need.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •