I created a Word macro-enabled template (.dotm) in Office 365. The DOTM contains 3 simple macros - AutoNew with message, AutoOpen with message, and a Userform with simple data entry code. The DOTM works as intended when loaded on my local computer's desktop and when accessed from OneDrive. That is, I can open for editing by right-clicking and selecting open and I can create an instance by double-clicking on the DOTM, which triggers the AutoNew macro. I am trying to achieve the same result in SharePoint Online.

I have a SharePoint Communication site with a Library. I uploaded the DOTM to the Library. When I right-click and select Open | Open in browser, no macro is triggered. Given the title (without any extension), I assume that the DOTM loaded and is presented with macros disabled. When I right-click from the Document list and select Open | Open in app, the AutoOpen macro is triggered and the DOTM is loaded. If I (left-)click on the file in the Document list (seems to activate on a single click), I receive a dialog box titled "Open Word?" If I click "Open Word", the AutoOpen macro is triggered and the DOTM is loaded - the same as when I right-clicked and selected Open in app. I assumed that accessing the file from the Document list in SharePoint would be the same as accessing in OneDrive (i.e., open instance with AutoNew macro triggered) but such does not appear to be the case.

Also, at the Document list, I clicked on the +New pull-down list, selected +Add template, and added the DOTM so that it now appears on the +New pull-down list. If I click on the DOTM in the +New pull-down list, I receive a blank page (titled "about:blank") and a new document titled "DOTM File.dotm" appears in the Document list. This is not what I seek either.

I would like to enable a user to click on the file and have an instance document load, triggering a (presumably AutoNew) macro that will contain a UserForm. However, neither including the DOTM on the Document list or adding the DOTM to the +New pull-down list appear to work.

Similar to unanswered inquiries in: Macro enabled template doesn't open Word in SharePoint Online 'New Experience' SharePoint Online - using Macro templates on the New button in a Library

1 Answer 1


This behaviour is expected. The macros do not run in Word Online (open in browser), as per the documentation.

Word Macro-Enabled Document (.docm) or Word Macro-Enabled Template (.dotm) The document can be opened, but macros do not run.

Differences between using a document in the browser and in Word

If you want these macros to run, you will need to set documents to open in client applications by default. You can do this either by changing this setting for the entire site or at library level.

SharePoint Online: Open Documents in Client Applications by Default

  • I understand that for right-click and "Open in browser", but if I (left-)click it appears to open in the app (same behavior as right-click and "Open in app"). Hence it seems to be working with non-browser version but - rather than the right-click "Open in app" - I would have thought it would instantiate a new document a run macros from the template. Regardless, thanks for the prompt response and the links; I will review carefully.
    – user107409
    Mar 20, 2023 at 20:01
  • Traditional office macros are built on top of VB code, which cannot run in the browser e.g. it's not a browser/client side language like JavaScript. For online versions of office web apps like Word/Excel Online, Microsoft have introduced Office Scripts which use JavaScript: learn.microsoft.com/en-us/office/dev/scripts/overview/excel Mar 20, 2023 at 22:42
  • Do remember to upvote or mark as answer, if the answer helped you. This will help inform the community. Mar 20, 2023 at 22:42
  • In Library, I go to gear icon and select “Library Settings” and “More Settings". Under General Settings, I click the “Advanced Settings” link. The default open behavior is listed as "Open in the client application". I click on the DOTM in Documents list and receive the "Open Word?" dialog and select "Open Word". An embedded macro indicates that AutoOpen was triggered. The title indicates that the DOTM is open. This is NOT what I want to happen (and not what happens if I select from OneDrive). A document based on the template should be created and AutoNew should be triggered.
    – user107409
    Mar 22, 2023 at 16:37
  • 1
    Thanks Callum. I appreciate your quick and concise answers as well as general willingness to assist. I tried to upvote as a re-direction is as good as direct resolution ... or at least close - but apparently I do not have sufficient "points" to register.
    – user107409
    Mar 22, 2023 at 21:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.