Word 2016 Save As Command Trigger VBA

Anonymous
2016-05-13T22:26:47+00:00

In previous versions of Office, When Clicking File>Save As, Word would invoke the FileSaveAs() command. I have a macro that is a sub command of this that prompts for additional document information. With this Macro is 2016 Clicking File>Save As seems to no longer invoke that command. 

Anyone know what command is invoked now? or any way to to get a macro to trigger when users click File>Save as in Word 2016?

Sub FileSaveAs()

     On Error Resume Next

     Dialogs(wdDialogFileSummar

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Jay Freedman 206K Reputation points Volunteer Moderator
    2016-05-16T19:19:05+00:00

    Hi Mike,

    For reasons known only to the wizards who built VBA at Microsoft, Word uses the special name AutoOpen, but Excel requires an underscore in Auto_Open. (More info here.)

    Also, Excel doesn't have a direct equivalent to Word's AutoNew (which runs when you start a new document based on a template that contains that macro). You may as well delete the AutoNew macro from the Excel sheet and just leave it in Word. If you need that functionality in Excel, see this thread.

    3 people found this answer helpful.
    0 comments No comments

5 additional answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 322.1K Reputation points MVP Volunteer Moderator
    2016-05-13T22:44:32+00:00

    I think that you may need to customize the ribbon of the quick access toolbar to include a button to run a macro to do what you want in addition to saving the document.

    0 comments No comments
  2. Jay Freedman 206K Reputation points Volunteer Moderator
    2016-05-14T02:15:00+00:00

    As of Word 2013, the Save As command on the File tab (a.k.a. "Backstage") doesn't invoke the actual FileSaveAs command to get intercepted by a macro named FileSaveAs, although the F12 key still does. Of course, there's no way to force users to press F12 instead of clicking the File tab...

    What you can do is create an event handler that fires on the DocumentBeforeSave event, which occurs regardless of which UI element is used.

    In your template, insert a class module, and use the Properties pane in the macro editor to rename the class module as EventClassModule. Add this code to it:

    Public WithEvents App As Word.Application

    Private Sub App_DocumentBeforeSave(ByVal Doc As Document, _

            SaveAsUI As Boolean, Cancel As Boolean)

        On Error Resume Next

        If SaveAsUI Then

            Dialogs(wdDialogFileSummaryInfo).Show

        End If

    End Sub

    Then insert a new regular module, and add this code to it:

    Dim X As New EventClassModule

    Sub AutoNew()

        Set X.App = Word.Application

    End Sub

    Sub AutoOpen()

        Set X.App = Word.Application

    End Sub

    Sub AutoClose()

        Set X = Nothing

    End Sub

    The File Summary Info dialog will now be shown for either kind of Save As before the file is saved to disk, and anything entered in the dialog will be included in the saved file. (The If SaveAsUI statement prevents the dialog from appearing when the command is Save instead of Save As. The first Save of a new document is executed as a Save As, so the dialog will appear then.)

    0 comments No comments
  3. Anonymous
    2016-05-16T13:38:44+00:00

    This looks and sounds very promising but I can't seem to make the event action trigger on any type of save event. Here is what I have in place. When I perform any type of save action it act's normally, no additional dialog prompt.

    0 comments No comments
  4. Anonymous
    2016-05-16T13:51:06+00:00

    After closing Word and opening a new document with the template it started working correctly. Looks like it may have just needed an event trigger, but is working now. Thanks!

    0 comments No comments