Macro changes functionality when assigned as button in Word 2016

macrosmicrosoft wordmicrosoft-word-2016ribbonsave as

When I create a SaveAs macro in Word 2016, it functions differently when I assign it to a command button on the ribbon (or on the quick access toolbar).

Macro:

Sub saveAs()
    Application.FileDialog(msoFileDialogSaveAs).Show 
End Sub

Expected/desired effect:

  • Open up a Save As dialog box.

What it actually does:

  • In VBA editor: it runs as expected and opens the SaveAs window.

    • This is true whether I hit run or use F5 (the run shortcut).
  • In Macro List (i.e., after selecting "View Macros"): again, runs as expected after clicking the "Run" button.

  • As Macro command Button: does not perform desired action

    • If file was previously unsaved, the macro button saves the file as "Doc1.docx" without ever opening a SaveAs dialog box.

    • If file has previously been saved, the button simply acts as a Save button and saves the current state to the existing file (again, without opening the dialog box).

My question:

Why does this happen and what can I do to make it work as expected?


Specs:
Word 2016 MSO (16.0.8229.2073) 32-bit on a Windows 7 machine

Note: This post is in response to an issue I'm having with a solution to this question.


Update:

I experience the same effect when I use Dialogs(wdDialogFileSaveAs).Show or even Dialogs(wdDialogFilePrint).Show.

  • Again, in both cases, the desired effect occurs in VBA editor but a button assigned to the macro acts differently (and undesirably).

Update2:

I experience the same lack of functionality after updating to the [currently] most recent version: 16.0.8229.2086

Best Answer

I solved the problem posted in your other question by simply renaming the macro, ensuring it's in the Normal document, and reassigning a button to it.

Hope this helps.

Related Question