runing the macro automatically to all existing and new documents - vba

I have macro that create the footer with author and date, but I need this macro to automatically run to all word document (existing and the new document) just I open the word file which I saved before or the new one so there we find in document the macro that I create

save your macro file as a word addin file or put your macro in your personal.doc file and will be available for all files.

Store it in ThisDocument as OnCreate method ("Private Sub Document_NewDocument" if I remember well). Save it as Normal.dotm template, so it will automatically call it created document. You can also store it as OnOpen, and start your macro from removeing footer - this way all documents you open will get your footer.

Related

Open the Windows Properties Dialog of open document while Inside Microsoft Word

I want a Word macro that opens the Window 10 Properties dialog box from inside Word for a Word document while it is open. My motivation is I want to rename the file with the document open, fully aware I can't save the changes until I close the document in Word.
I have always been annoyed you can't rename a Word document while it's open. BTW Save As creates a new document and doesn't preserve the file's original creation date.

.dotm opens differently from .docm

Sean W 2104 post Auto displaying form on opening a template file, dotm from explorer demonstrated how to show my form when my .docm document loads.
Timothy Rylatt's response to my vba word 2016 saveas document without changing module name suggested I render my .docm as .dotm template.
However, though my .docm shows my first form on startup, opening the .dotm does not. The .dotm only shows only the underlying document (that the forms populate).
So is it that my forms (and their VBA code) do not belong in the template document they fill? Do I instead need to load a template document that doesn't contain the forms? If so, do I create a dummy .docm document whose only purpose is to house the forms (and their VBA code?) If so, what do I do with the document from the dummy? Hide it? And what does my prospective client open?
You do not name your procedure Document_Open in your template but rather Document_New.
You are not opening the template, but rather creating a new document based on that template. Here is my writing on Auto Macros in templates.
You could also name the procedure AutoNew and place it in the another module of your template.

Save macro enabled document as new template

I created a Word 2010 template with macros and VBA code but then I amended one of the documents created from the template instead of the template and this included text boxes and drop down lists. How do I save the document as a new template with the macros maintained as well as the VBA and components such as text boxes etc. When I try and save the document as a .dotm file the option to place in Design Mode doesn't work and I have took the document out of Compatibility Mode.

Install a Macro With a Batch File

I have a macro for Word that I would like to share with people, I want to create a batch file that installs the macro into word and assign it to a button.
Here is the batch file I have right now:
copy "Collapse.dotm" = "%appdata%\Microsoft\Word\STARTUP"
"%programfiles(x86)%\Microsoft Office\Office15\Winword.exe" /mCollapse
First the batch script copies the macro to the Word Startup folder. Then the script launches word, I ran the script and it is telling me it can't copy the macro.
EDIT: The error message was that Word could open up the template, I changed the extension to .dot instead of .dotm. With that change the script runs without errors, the template can be seen in the VBA Editor but doesn't create a macro.
EDIT 2: It creates a new project in the VBA that is unviewable though.

Saving dotm to docm - embed macros in docm

When I save a .dotm file with macros to a .docm file, the macro's aren't embedded in the .dotm file.
When I send the file to a colleague, he needs the .dotm, along with it to be able to use the macro's.
I want the code to be embedded in the .dotm, so it can be used as a standalone file.
Any way to do so?
I've seen this in cases where the .dotm is opened using a double click, and a new document is created from the .dotm by default. In this case the new document links to the macros in the template but does not copy them into the document. When you save the .dotm as a .docm, you're opening the original template and not working with a new document, right?