![]() |
#1
|
|||
|
|||
![]()
I want to create a macro that starts when a placeholder gets focus or gets changed. I have googled it but found nothing. Isn't this possible?
We use Word 2016. |
#2
|
||||
|
||||
![]()
That's quite easy if your placeholder is a formfield (in a document with forms protection), content control or ActiveX control serving as the placeholder, but not otherwise. What is your placeholder?
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#3
|
|||
|
|||
![]()
It is at content control.
|
#4
|
||||
|
||||
![]()
In that case, you'd use a Document_ContentControlOnEnter macro to the Document's 'ThisDocument' code module. The skeletal structure is:
Code:
Private Sub Document_ContentControlOnEnter(ByVal ContentControl As ContentControl) End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
![]()
It works, thanks!
But this macro starts each time any content control gets focus. So I need to either change the code so it just starts when a specific content control is marked or do something like: Code:
Private Sub Document_ContentControlOnEnter(ByVal CC As ContentControl) If CC.Title like "Leder" Then doSomeThing End Sub ![]() |
#6
|
||||
|
||||
![]()
Yes, if you want to restrict the response to one or more content controls, you need to specify which one(s) to act on or to exclude. That can be done via the content control's Title and/or Tag, or its relative position in a defined range (i.e. Document, Section, Table, etc.).
There are plenty of examples of that on this forum, though usually in the context of a ContentControlOnExit macro. A search for 'ContentControl' will turn up numerous examples.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Tags |
macro in word, placeholder |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Phil H | Excel Programming | 3 | 06-18-2015 01:20 PM |
difference between scheduled start and start | ketanco | Project | 3 | 01-15-2015 07:53 AM |
![]() |
tinfanide | PowerPoint | 1 | 04-05-2013 10:37 AM |
Should be a simple macro, need a start | Jamtart | PowerPoint | 7 | 08-13-2012 06:11 AM |
automatic start of macro + help on writing helper function | vsempoux | Word | 3 | 10-09-2009 03:01 AM |