Hide custom controls group on ribbon in word - vba

Some background first. Im creating VBA script to transform one Word document into another one. I developed a script and put it into dotm template file.
First appication is using this template to export data. Next script in this template transforms exported data into new document. This template is also used to create result document. This means that all styles, scripts and custom ribbon UI is available in result document.
What I need is to remove scripts and custom ribbon UI from result document.
I was able to remove scripts but I don't know how to access and remove or hide custom ribbon UI from result document.
Any hints? Btw I don't want to put any script in result document which means that script from template have to delete or hide custom robbin UI from result document.

When you create the target document Word will use the current attached template. You need to specify a different template e.g. Normal.dotm. (assuming you are not developing your scripts in Normal.dotm.

Related

.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.

Customize ribbons for every MS Word document

I am new to development with VBA. I am working on a project based on MS Word macros.
Lately, I have been trying to create ribbons to access certain functionalities, but I have got limited success in it.
I want to customize ribbons using XML which should appear on all MS Word files and not the one I have used to customize ribbon.
Is there any way to create any XML file that can be utilised by all MS word documents without having to customize each one of them.
Thanks..
Regards
The answer for this is essentially the same as for making macros available to all documents:
Store the Ribbon in a template (together with the macros, so a dotm) and load it as an Add-in.
If it should load automatically, that means placing it in Word's STARTUP folder.

Running VBA macros in documents created using template

I have macro-enabled templete (.dotm) wich has number of macros generally connected with adding and deleting parts of document using custom building blocks stored in the template.
When I execute macros at the actual template file everything works smooth.
But when I try to execute them in documents created using this template macros stop working after one run of the particular function (attached to checkbox).
Additionally in some cases checkboxes turn into pictures when saving documents as .docx files.
What could be wrong with this document?
The problem was solved by recreating problem checkbox.

New document-button behave as the Transfer documents-button

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.

How to get the template path of a word 2003 document

When I create a new document based on a template (*.dot), I need to know on which template is the document based on.
Is there a way to find out with VBA which template was used for creating this new document? I need the complete path to the template.
ActiveDocument.AttachedTemplate.FullName
You may also use a built-in document property to access the template name: ActiveDocument.BuiltInDocumentProperties(wdPropertyTemplate)
I don't remember why theres has been sometimes differences between the two results; you must try it out. please be aware that accessing sometimes the built-in properties sets the document in a dirty state, so that it is useful to save the ActiveDocument.Saved state before and reset it after having accessed the property.
[UPDATE]
I've had again a look into the way you're creating the documents. If it's at your customer with 38.000 templates, I guess your problem are "fake" templates. I've just did a test with Office 2003:
Create a new document "TestTemplate.doc" with same content and save it as doc file. Close it.
Go to Windows Explorer and rename the document to "TestTemplate.dot". This provokes Windows Explorer to treat it as a template, not as a document. The default DDE command for templates is not "OPEN", but "NEW", what you can also see if you do a right-click on the file ("New" is bold, while with documents "Open" is bold).
Double-click the fake template: Word creates a copy of the document, so a new file named "Document2" or whatsoever.
Go to the VBA Editor, and type ?ActiveDocument.AttachedTemplate, and you'll see "Normal" as answer. Type ?activedocument.Type = wdTypeTemplate and you'll see "False" as answer.
Sp I guess the documents "Without template" are only copies of other documents, and not of templates. So you have no way to find the base template.