Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-07-2017, 11:41 PM
ArtKilp ArtKilp is offline Listbox Content Control - Reset default/prompt? Windows 8 Listbox Content Control - Reset default/prompt? Office 2016
Novice
Listbox Content Control - Reset default/prompt?
 
Join Date: Jan 2016
Posts: 18
ArtKilp is on a distinguished road
Default Listbox Content Control - Reset default/prompt?

Let's say we have a list box. We have there a prompt "Pick value" and the options are "1", "2" and "3". User picks value "3". Now in order to reset this value to "Pick value", what do I need?



This
Code:
Dim obj 
Set obj = ActiveDocument.ContentControls(2) 
obj.Range.Text = obj.PlaceholderText.Value
fails to "You are not allowed to edit this selection because it is protected".

And yes, I've asked this elsewhere too.
Reply With Quote
  #2  
Old 08-08-2017, 12:30 AM
macropod's Avatar
macropod macropod is offline Listbox Content Control - Reset default/prompt? Windows 7 64bit Listbox Content Control - Reset default/prompt? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

That's as simple as:
Code:
ActiveDocument.ContentControls(2).Range.Text = ""
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 08-08-2017, 01:20 AM
gmayor's Avatar
gmayor gmayor is offline Listbox Content Control - Reset default/prompt? Windows 10 Listbox Content Control - Reset default/prompt? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,104
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Unfortunately it isn't and will produce the same error. For a list box the code required is
Code:
ActiveDocument.ContentControls(2).DropdownListEntries(1).Select
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #4  
Old 08-08-2017, 01:23 AM
ArtKilp ArtKilp is offline Listbox Content Control - Reset default/prompt? Windows 8 Listbox Content Control - Reset default/prompt? Office 2016
Novice
Listbox Content Control - Reset default/prompt?
 
Join Date: Jan 2016
Posts: 18
ArtKilp is on a distinguished road
Default

Quote:
Originally Posted by gmayor View Post
Unfortunately it isn't and will produce the same error. For a list box the code required is
Code:
ActiveDocument.ContentControls(2).DropdownListEntries(1).Select
That gives me the first option from the list. I want the prompt, not the option. Programmatically logical would be "-1" or "0" or something like that. Or "ActiveDocument.ContentControls(2).Reset()"

The best option I've found so far has been to re-create the entire list. It is a lot of hopefully completely needless code, but that's the best solution I've found working.
Reply With Quote
  #5  
Old 08-08-2017, 03:11 AM
macropod's Avatar
macropod macropod is offline Listbox Content Control - Reset default/prompt? Windows 7 64bit Listbox Content Control - Reset default/prompt? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by gmayor View Post
Unfortunately it isn't and will produce the same error.
It worked when I tried it before posting, but when I re-tried it just now, it didn't. Another way would be:
Code:
With ActiveDocument.ContentControls(2)
  .Type = wdContentControlText
  .Range.Text = ""
  .Type = wdContentControlDropdownList
End With
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 08-08-2017, 03:29 AM
ArtKilp ArtKilp is offline Listbox Content Control - Reset default/prompt? Windows 8 Listbox Content Control - Reset default/prompt? Office 2016
Novice
Listbox Content Control - Reset default/prompt?
 
Join Date: Jan 2016
Posts: 18
ArtKilp is on a distinguished road
Default

Quote:
Originally Posted by macropod View Post
It worked when I tried it before posting, but when I re-tried it just now, it didn't. Another way would be:
Code:
With ActiveDocument.ContentControls(2)
  .Type = wdContentControlText
  .Range.Text = ""
  .Type = wdContentControlDropdownList
End With
This works, thanks!
Reply With Quote
  #7  
Old 08-08-2017, 04:48 AM
gmayor's Avatar
gmayor gmayor is offline Listbox Content Control - Reset default/prompt? Windows 10 Listbox Content Control - Reset default/prompt? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,104
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Quote:
Originally Posted by macropod View Post
Another way would be:
Code:
With ActiveDocument.ContentControls(2)
  .Type = wdContentControlText
  .Range.Text = ""
  .Type = wdContentControlDropdownList
End With
That is suitably ingenious. Good one
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #8  
Old 08-08-2017, 05:31 PM
macropod's Avatar
macropod macropod is offline Listbox Content Control - Reset default/prompt? Windows 7 64bit Listbox Content Control - Reset default/prompt? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Cross-posted at: http://www.vbaexpress.com/forum/show...-Reset-default
For cross-posting etiquette, please read: http://www.excelguru.ca/content.php?184
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Listbox Content Control - Reset default/prompt? Clicking the selected Content Control checkbox returns wrong control in vba event DougsGraphics Word VBA 2 06-24-2015 07:31 AM
How to set the Content Control placeholder default text dsimon14 Word VBA 3 03-27-2015 07:15 AM
How to use an ActiveX Control to insert a multi select listbox in Word marksm33 Word 2 01-29-2014 05:21 PM
Listbox Content Control - Reset default/prompt? Deleting a table from a content control -- preserving the content control BrainSlugs83 Word Tables 8 11-14-2013 03:06 AM
Listbox Content Control - Reset default/prompt? text appears in prompt font in RTF content control eli.rhodes Word 1 09-18-2013 08:32 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:49 AM.


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