Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-03-2014, 10:33 AM
gmaxey gmaxey is offline Option Button selected will display text Windows 7 32bit Option Button selected will display text Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,617
gmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nicegmaxey is just really nice
Default

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
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #2  
Old 07-03-2014, 10:42 AM
ksigcajun ksigcajun is offline Option Button selected will display text Windows 7 64bit Option Button selected will display text Office 2010 64bit
Advanced Beginner
Option Button selected will display text
 
Join Date: May 2014
Posts: 76
ksigcajun is on a distinguished road
Default

Quote:
Originally Posted by gmaxey View Post
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
This works great Greg! Thank you so much. Very helpful.

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!
Reply With Quote
Reply



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
Option Button selected will display text 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

Other Forums: Access Forums

All times are GMT -7. The time now is 11:25 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