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.
Related
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.
I already have .docm files that have simple formatting macros embedded in them. The macros work. However I have 100+ different .docm files that use basically the same macro. Instead of changing the macros on all 100+ .docm files when I need to change a format, I would like to place the macro in a separate text file in a stable location on a network drive and have the macro code in each .docm file reference that text file.
I tried a Call Shell(AppName,1) statement where the AppName contains the path of the txt file, but the compiler won't work with a colon.
I researched creating a macro to change other macros embedded within each document, but was advised against it due to virus scanners.
It's not possible to run a macro from a text file, the way you imagine. (Cool idea, but a security risk, I think.)
Better would be to bring all the macros together in a single template (dotm), which you put in your STARTUP folder. When Word loads, it will load this template (with all its Ribbon customizations and macros) as an "add-in". (See also the Developer/Add-ins dialog box, which is where these can be managed.)
In this way, your code can be managed centrally - but you do have to explicitly open the template in order to make changes to the code. It can't be done just over the loaded add-in (that's only possible with Normal.dotm).
You can also have macros in this add-in template that you call from other macros. This can be done using the Applicaton.Run method.
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?
In an ordinary document list in SharePoint 2010 there are two buttons for adding documents: “New document” and “Transfer documents”. New document usually opens a blank word document, and Transfer documents usually gives the possibility to choose a document to add to the list.
In a document library in our environment, the New document button opens the form to upload an existing file rather then open an empty word document.
Why does this happen? Is there a setting that specifies this behavior?
It happens when there are no default templates, possible due to custom content types with no set default document template (word, excel, etc) pherhaps due to upgrade from SP 2007 to 2010?
Quick fix: Add document template to the custom content type and add document should reappear.
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.