none
VBA Macro created in Word Template not running when template is launched in Internet Explorer

    Question

  •  

    Hello:

      I have a Word template that contains a VBA application. This application is launched through a macro and runs fine when I double click and open the template using MS Word. However, when I tried to open the same WORD template file in Internet Explorer (this is the final requirement), it fails to launch the application or run the macro. I am already using the following code in the ThisDocument.Open subroutine of the template:

     

    ActiveDocument.RunAutoMacro wdAutoOpen

     

    This worked once, but then suddenly stopped working! I am unable to find help on microsoft KB or anywhere else. Appreciate any help in this regard.

     

    Sincerely

    Prasad

    Wednesday, October 03, 2007 10:22 PM

Answers

  •  

    Appreciate your help. I had already tried running the same macro using the New event as well. No luck there. However, finally we created a shortcut to the .dot file and provided a hyperlink to the shortcut file on the browser. This seemed to do the trick. Our problem is resolved now. Thanks for your help!

     

    Regards,

    Prasad

    Monday, October 08, 2007 3:01 PM

All replies

  • It could be an internet explorere security setting. If the Word file is on a network path, try changing the "local intranet" security settings to allow macros (the default "medium" setting should be OK). Also check the sites that are assigned to local intranet to enable the one(s) you need. Unfortunately, if this is the problem, the setting will probably need to be changed on each computer.
    Thursday, October 04, 2007 7:48 AM
  • Thanks for the suggestions. The internet security setting has already been set to "Medium" but it is not helpful. I even generated a temporary digital certificate for the macro. This has not helped either. Appreciate any other inputs or help.

     

    Regards,

    Prasad

    Thursday, October 04, 2007 3:09 PM
  • When you say template, do you mean template in the MS Word sense (ie a .dot extension), or do you just mean a document (.doc extension) that you are using as a base or pro-forma document?

     

    If you really mean template in the MS Word sense, then when you say you open the template, are you opening the template itself or opening a new document that uses that template? If the latter, I think the Open event in the template will not be triggered, because the template itself is not being opened.

     

    In any case, after the document has been opened via internet explorer, is the macro available at all? Can you still run the macro manually or is it completely disabled?

    Friday, October 05, 2007 2:20 AM
  •  

    You may be getting closer to the problem. Yes, it is a MS Word template (.dot) that I am referring to. When I open the .dot file normally from windows, it launches the VBA form after prompting for enable/disable macros, in a new document (document1). However, if a hyperlink is provided to the file or a javascipt is used (windows.open script) to open the .dot template, it does not prompt for the enable/disable macros! As you are suggesting, this maybe because the document's Open Event is not being triggered.... Finally, yes the macro is still available thru' the menu options and can be run manually. However, our ultimate goal is to provide a link on the homepage so employees from around the world can just click on a link and launch the VBA forms we have designed and use them... The web hyperlink is simply opening the .dot file in MS Word without running the macros. Appreciate your help.

     

    Regards,

    Prasad

    Friday, October 05, 2007 5:49 PM
  • OK. I realise you wanted it to run automatically, but knowing that the macro is available and works, but doesn't auto run means we can probably narrow it down to an issue with the auto run not triggering.

     

    Now that I know it really is a template, that explains why the Open event isn't triggering.

     

    Try changing the macro in the template so that it uses the New event rather than Open. Open is triggered when the document itself (the template in this case) is opened, where New triggers when a new document is created using the document as a template.

    Note the New event will only run from a template, not from a normal document.

    Saturday, October 06, 2007 7:10 AM
  •  

    Appreciate your help. I had already tried running the same macro using the New event as well. No luck there. However, finally we created a shortcut to the .dot file and provided a hyperlink to the shortcut file on the browser. This seemed to do the trick. Our problem is resolved now. Thanks for your help!

     

    Regards,

    Prasad

    Monday, October 08, 2007 3:01 PM
  • I have faced similar problem, so i tried the following

    Go to "Folder Options" -> "File Types" in explorer
    select the extension (ie. doc)
    click on "Advanced" button
    Check the "Browse on same window"

    try to open the macro now and check it

    Hope this helps.
    All the bese

    Regards,
    Nivas S
    Monday, December 22, 2008 2:56 PM
  • Hi there

    Been in the same situation myself and found a workable solution. Instead of linking to the template from your web page, put it in a zip file and link to the zip file. The person will then open the zip file and can run the template with macros by opening it from the zip file itself as it is now local so gets around the security restrictions.

    Regards
    Harel

    Thursday, October 21, 2010 1:04 PM
  • Sorry, but that will not get around the security restrictions as the zip folder will not be a trusted location.

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Harel Seligmann" wrote in message news:22cd53a8-1dd1-425a-b08d-1ec5858bbd07@communitybridge.codeplex.com...

    Hi there

    Been in the same situation myself and found a workable solution. Instead of linking to the template from your web page, put it in a zip file and link to the zip file. The person will then open the zip file and can run the template with macros by opening it from the zip file itself as it is now local so gets around the security restrictions.

    Regards
    Harel


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Thursday, October 21, 2010 9:52 PM
  • Doug - would have to disagree with you on that one as I've done it and it works. When you open the zip file it is putting it in a temporary folder on your pc. When you click on the excel file from the zip file, you are actually opening a local copy from your pc and not opening a file from the web. This is the reason why you no longer have the security issue from the web browser.
    Monday, November 15, 2010 6:34 PM
  • That may be the case with some versions of Office, but not with the latest.

    -- Hope this helps.

    Doug Robbins - Word MVP,
    dkr[atsymbol]mvps[dot]org
    Posted via the Community Bridge

    "Harel Seligmann" wrote in message news:fc9ceb98-3ac6-4fc3-a206-1ede5f27e751@communitybridge.codeplex.com...

    Doug - would have to disagree with you on that one as I've done it and it works. When you open the zip file it is putting it in a temporary folder on your pc. When you click on the excel file from the zip file, you are actually opening a local copy from your pc and not opening a file from the web. This is the reason why you no longer have the security issue from the web browser.


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org
    Tuesday, November 16, 2010 12:19 AM