Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 07-26-2023, 04:23 PM
Journeyman Journeyman is offline How to find the content control ID after selection Windows 10 How to find the content control ID after selection Office 2019
Novice
How to find the content control ID after selection
 
Join Date: Feb 2023
Posts: 15
Journeyman is on a distinguished road
Default How to find the content control ID after selection

Hi All,

I have a word document with several ActiveX Textbox controls laid out in a form.

I need an event to run on the selection of those controls - specific to the selected control. For some very odd reason Microsoft chose to remove the events for ActiveX controls, so now I'm left trying to code events to trap a change.

This will return true if my selection is within an ActiveX Content Control
Code:
Selection.Infomation(wdInformation.wdInContentControl)
Surely you'd think more could be provided by the information than just a Boolean value.

This will return Text within a specific (or known) control
Code:
ActiveDocument.ContentControls(strControlName).range.text
Where strControlName is the known title or ID of the control.... except I don't know it until it's selected.

This apparently returns the ID of the selected control - if it is in design mode
Code:
Selection.range.ContentControl(1).ID
Although I've never been able to make that work in any way... doesn't exist error.

And I can loop through all control on the document to return all control information.


Code:
For i = 1 to ActiveDocument.ContentControls(i).count
     Debug.Print ActiveDocument.ContentControls(i).ID
Next i
All of this is fabulous and wonderful... except not a single method provides for the selection of the control itself.

What is the secret to returning the selected control - and it's corresponding text or information?

Alternatively - and this would be magic sauce - an AfterUpdate event of some kind for the control (doesn't exist in word, i know, but... magic.

All help appreciated.

Cheers
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
font color based on content control pulldown selection PbFoot Word VBA 3 01-03-2023 08:22 AM
Lock or unlock a content control depending on the selection from the drop down list ncruz Word VBA 4 10-15-2021 08:50 AM
How to find the content control ID after selection Edit table cells based on content control selection gennatr12 Word VBA 7 03-26-2017 08:51 PM
How to find the content control ID after selection How do I add selection of multi line content control list to specific table cell Dudlee Word VBA 1 09-20-2016 04:58 PM
Combo Box Content Control Calculate on selection help ciresuark Word 0 03-06-2015 01:49 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft