Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-15-2015, 08:48 AM
ksigcajun ksigcajun is offline Option Button help Windows 7 64bit Option Button help Office 2010 64bit
Advanced Beginner
Option Button help
 
Join Date: May 2014
Posts: 76
ksigcajun is on a distinguished road
Default Option Button help

I have two option buttons for users to select one or the other.

I currently have some text with content control fields in a paragraph (bookmarked BM4) below the buttons. If a user chooses OptionButton1, it would do nothing, but keep the text present. If OptionButton2 is chosen, it would delete the text which is in Bookmark BM4.

I would like OptionButton1 to not only do nothing if chosen first, but Id love for it to undo the deletion in case a user chooses OptionButton2 first and decided it wanted to keep the text and chose OptionButton1.

My code in OptionButton1 isnt working properly. Any help?

PHP Code:
Private Sub OptionButton1_Click()
If 
Me.OptionButton1.Value True Then
ActiveDocument
.Undo
End 
If
End Sub
 
Private Sub OptionButton2_Click()
If 
Me.OptionButton2.Value True Then


  ActiveDocument
.Bookmarks("BM4").Select
Selection
.Delete
End 
If
End Sub 
Reply With Quote
  #2  
Old 01-15-2015, 01:36 PM
gmaxey gmaxey is online now Option Button help Windows 7 32bit Option Button help Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,422
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

If you are using a content control (e.g., one titled "TextCC") then you don't need a bookmark for this:

Code:
Option Explicit
Private strVal As String
Private Sub OptionButton1_Click()
  If Me.OptionButton1.Value = True Then
    ActiveDocument.SelectContentControlsByTitle("TextCC").Item(1).Range.Text = strVal
  End If
End Sub
 
Private Sub OptionButton2_Click()
  If Me.OptionButton2.Value = True Then
    strVal = ActiveDocument.SelectContentControlsByTitle("TextCC").Item(1).Range.Text
    ActiveDocument.SelectContentControlsByTitle("TextCC").Item(1).Range.Text = vbNullString
  End If
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Option Button selected will display text ksigcajun Word VBA 7 07-14-2014 09:31 AM
Option Button help How to run two button macros with one button? Geza59 Excel Programming 1 02-14-2013 12:11 AM
printing option JadePriest Excel 1 09-21-2012 10:27 AM
Help on option button active X aligahk06 Excel 0 11-03-2009 11:39 PM
Option Button ( ACtive X Control ) aligahk06 Excel 0 11-03-2009 06:36 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:02 PM.


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