Word 365-SP Content Type Document Template and BeforeSave Event_Issue 1 Macrobutton on New Document 2. BeforeSave on New Document

Jimmie Traylor 1 Reputation point
2021-05-22T04:54:48.14+00:00

I have a Word Doc linked to a SharePoint Content Type to use on 100's of Document Libraries. I set up the Document Template for this Content Type to have 3 MacroButtons. One of the MacroButtons is linked to a Save Document Macro that automatically names the file based on fields in the document which works fine when testing from the original document in the document library it is stored in. I can enter date into the fields, press the button and a new file gets saved in a new document library on a site related to one of the field values.

Issue 1
When I open a document for this Content Type in any of the Document Libraries, the MacroButtons do not work. I have them set to work with 1 click (the double click feature is one of the worst ideas) but neither a single click or a double click seems to trigger the Macros. One of the reasons we have the Save Button is to make sure file names are standardized and the Save As UI has changed and no longer gives the current document library as the save to destination by default (users are constantly having trouble finding the correct document library to save in). How can I get the MacroButtons to trigger the Macros assigned on the New Document.?

Issue 2.
When the New Document is opened from the Document Library and someone hits the Word Default Save Button, the BeforeSave Event does not activate. I have Code in the BeforeSave Event to check if the Button was pressed (when the button is pressed i update a document property and check in the BeforeSave Code for that updated value) and if it was not then a Message Box tells them they have to use the button. On the New Document it automatically brings up the Save As UI as if the Before Save is not recognized. Again this works correctly from the Original Document.

I think the issues are related in that none of the VBA seems to be recognized on the New Document even though they are in the Document. I actually have about 9 different documents that need to work the same way so if anyone has any idea how i can fix these issues it would solve a lot of problems. I can provide a sample document if someone needs it.

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,827 questions
{count} votes

1 answer

Sort by: Most helpful
  1. MichaelHan-MSFT 18,036 Reputation points
    2021-05-24T06:28:53.507+00:00

    Hi @Jimmie Traylor ,

    Paul's answer in this post would be helpul to you: https://social.technet.microsoft.com/Forums/en-US/5b5a08ee-eb48-4187-8874-484f8ad5e614/macros-in-a-sharepoint-content-type-document-template-do-not-execute?forum=sharepointgeneralprevious

    SharePoint Document templates aren't the same as Word templates. All Office templates are required to be stored on the local computer or a network drive mapped by the local computer. Although you can use a .dotx or .dotm as a SharePoint template. when you create a new document from a SharePoint Library it just makes a copy of the file and renames it as a document1.docx. The actual Office template used will revert to the template behind the .dot in SharePoint, normally the normal.dot in Word. As a result the macros aren't actually wired up in the file anymore since they were wired up by the template.


    If an Answer is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.