workssuper.blogg.se

Vba does selectcontentcontrolsbytitle work on word for mac
Vba does selectcontentcontrolsbytitle work on word for mac












vba does selectcontentcontrolsbytitle work on word for mac

NB for this to work, tb1's "contents cannot be edited" property has to be unchecked Private Sub Document_ContentControlOnExit(ByVal ContentControl As ContentControl, Cancel As Boolean) This will "fire" when you click outside the dropdown control or tab out of it.

vba does selectcontentcontrolsbytitle work on word for mac

Then you can put the following VBA in your ThisDocument module. So let's imagine your dropdown has Title dd1, you are going to put your text in a plain text content control titled tb1, and your dropdown's "display names" are my display name 1, my display name 2 and so on. Your VBA then needs to know where to display the text and what text to display. Then you need an event to run your VBA - you can either use a content control event or if you map your content control to a Custom XML Part, you can use a "Datastore" event (linked to the XML Part). If you go the VBA route, let's assume you are going to use a Content Control dropdown. Or you can protect a section of the document, in which case the user gets to edit the remainder of the document, with some restrictions. You then have to "protect the document for forms", which means that the user can't do any editing other than filling in the form. At its simplest you could use one IF field for each dropdown value, so if the dropdown had values "abc", "def", "ghi" etc. Then you set up one of more fields that display the text you want, using the "display name". The display names are limited to something like 50 characters. The names have a length limitation (32 characters I think).įor (b), you create a legacy formfield dropdown with the "display names" that you want, and set the form field to "calculate on exit". The building block names and content are displayed in the "dropdown". The selected entry's content is displayed directly in the control. You basically choose a (predefined gallery and create a category, put all the entries you want to display in the dropdown in that gallery/category, then set up the Building Block Content control's properties to use that gallery/category. AFAIK the building block mechanism is not available on Mac. So if you want a single-file solution you have to make your document a. As soon as you use VBA, there are a number of possibilities.įor (a), Building Block entries have to be in a Word template or special building block template. (a) and (b) are the only approaches I can think of that don't need VBA.

vba does selectcontentcontrolsbytitle work on word for mac

use a legacy form field dropdown and a field that inserts the value you want depending on the value selected. one you create specifically for this control).ī. put all your texts in Building Block entries in a specific Gallery (e.g. There are several possibilities, each with their own advantages and disadvantages. The value can't have more than 255 characters and in any case is not shown in the document - even to do that you would have to "map" the content control to an element in a Custom XML Part, map a plain text content control to that element and put that control in the document.














Vba does selectcontentcontrolsbytitle work on word for mac