#1
|
|||
|
|||
Option Button selected will display text
Im working with two option buttons in Word and I want to display specific text below each if that button is chosen. Can a simple macro be written?
Here is what should happen. If Option Button111 is selected, the following text will be displayed, "User will email form." If Option Button211 is selected, the following text will be displayed, "User will mail form via FedEx." This is what I got, so far. Am I on the right track? Should I have two seperate macros or can this be written into one? Thanks! Code:
Private Sub OptionButton111_Click() If Me.OptionButton111.Value = True Then End Sub Private Sub OptionButton211_Click() If Me.OptionButton211.Value = True Then End Sub |
#2
|
|||
|
|||
Yes you are on the right track, but ActiveX controls are not ideal for use in Word documents.
You need a range target for the text. It could be a table cell, a paragraph, a bookmark, a content control, a variables (and use a DocVariable field), etc. Here I have created a bookmark "bmText" to serve as the target range. Code:
Option Explicit Dim oBM As Bookmark Dim oRng As Range Private Sub OptionButton111_Click() If Me.OptionButton111.Value = True Then Set oRng = ActiveDocument.Bookmarks("bmText").Range oRng.Text = "User will email form" ActiveDocument.Bookmarks.Add "bmText", oRng End If End Sub Private Sub OptionButton211_Click() If Me.OptionButton211.Value = True Then Set oRng = ActiveDocument.Bookmarks("bmText").Range oRng.Text = "User will mail form via FedEx" ActiveDocument.Bookmarks.Add "bmText", oRng End If End Sub |
#3
|
|||
|
|||
Quote:
Quick question, is there a way to remove the text if someone changes their mind and wants to chose the other option button? I noticed when I do that now, it leaves the text. Thanks! |
#4
|
|||
|
|||
Here if I choose OptionButton111 the bookmark text is "User will email form." If I change my mind and choose OptionButton211 the bookmark text changes to "User will mail form via FedEx"
I don't know why it wouldn't be working the same for you. |
#5
|
|||
|
|||
Quote:
Does it currently do that for you? |
#6
|
|||
|
|||
Yes, the text displayed here is the text associated with the option button selected.
|
#7
|
|||
|
|||
Quote:
I'm trying to come up with Plan B. Can I clear the text in the bookmark? Here is where Im at. Code:
Option Explicit Dim oBM As Bookmark Dim oRng As Range Private Sub OptionButton111_Click() ActiveDocument.Undo If Me.OptionButton111.Value = True Then Set oRng = ActiveDocument.Bookmarks("BM2").Range oRng.Text = "Bids should be sent via email to the email addresses listed above. In the alternative, if Bidder does not intend to bid on this Project, please submit your confirmation of NO BID via email to the email address listed above." ActiveDocument.Bookmarks.Add "BM2", oRng If Me.OptionButton211.Value = False Then **Not sure what I can add here to clear the text** End If End If End Sub Private Sub OptionButton211_Click() ActiveDocument.Undo ActiveDocument.Undo If Me.OptionButton211.Value = True Then Set oRng = ActiveDocument.Bookmarks("BM3").Range oRng.Text = "All bids must be sealed and received at the address listed above. Any bid received after that time may, at COMPANY'S sole discretion, be returned unopened. The bid opening will be private. In the alternative, if Bidder does not intend to bid on this Project, please submit your confirmation of NO BID via email to the email addresses listed above." ActiveDocument.Bookmarks.Add "BM3", oRng If Me.OptionButton211.Value = False Then **Not sure what I can add here to clear the text** End If End If End Sub |
#8
|
|||
|
|||
Nevermind, Greg.
I was able to correct the issue. Thanks again for the help! |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Display paragraph of text based on value selected in combo | WordWaza | Word | 0 | 08-09-2013 06:30 AM |
Can you create a button that indicates the status of markup display? | New Daddy | Word | 1 | 01-25-2013 12:35 AM |
Recent file display option at MS word | Patrick Lau | Word | 0 | 08-16-2010 11:22 PM |
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 |