none
AutoOpen/AutoExec don't fire when file is opened with double-click RRS feed

  • Question

  • Hi,

    I have been trying to write a macro for which user input is provided via a form. I want this form to be auto displayed whenever the dotm file containing the macro is opened. I want my macro to be self contained so that I can simply distribute a dotm file to users, and when they open it they brought straight to the form.

    I have been trying to do this with AutoOpen or AutoExec but it doesn't work as I expect.

    If word is already open and I open my dotm file via File...Open... the form displays as expected which is good. However if I open the file by double click from explorer, the form doesn't display.

    I have tried simplifying this so that all AutoOpen or AutoExec contains is a MsgBox("test") like this:

    Public Sub AutoOpen()
       MsgBox("test")
    End Sub

    but this doesn't work either.

    I understand that AutoOpen is supposed to run any time the file is opened, but it doesn't. AutoExec is supposed to run any time word is initialised, but it doesn't.

    In Word trust center has all macros enabled, and the file is in a trusted location.

    I've been googling for hours and my head is spinning. What am I doing wrong?

    Cheers,

    Fraser

    Monday, June 30, 2014 2:55 PM

Answers

  • Hi Fraser

    Which version of Word and Windows?

    If the user is double-clicking on a template file that will generate a NEW DOCUMENT based on the template, so AutoOpen won't trigger. Have you tried it with AutoNew?


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by FrazW Monday, June 30, 2014 5:40 PM
    Monday, June 30, 2014 2:59 PM
    Moderator

All replies

  • Hi Fraser

    Which version of Word and Windows?

    If the user is double-clicking on a template file that will generate a NEW DOCUMENT based on the template, so AutoOpen won't trigger. Have you tried it with AutoNew?


    Cindy Meister, VSTO/Word MVP, my blog

    • Marked as answer by FrazW Monday, June 30, 2014 5:40 PM
    Monday, June 30, 2014 2:59 PM
    Moderator
  • Hi Cindy,

    Ah!! I had misunderstood that AutoOpen pertained to any word file type rather than documents specifically.

    I switched it to AutoNew and it all worked like a charm and I feel slightly embarrassed :)

    For future reference, Word 2013 on Windows 7 Enterprise and also Windows 8.1.

    Thank you very much for your help :)

    Monday, June 30, 2014 3:17 PM