p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > Microsoft Office > Other Office > Word VBA
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Word VBA Discuss using VBA to program Word.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Word VBA section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 5th, 2009, 06:05 AM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2009
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Mupltiple Check Boxes

Hi Guys,

I am new to VBA and have managed to get this far using books and help files on the internet. I would like to know if it is possible to amend the code to allow this to work on multiple checkboxes, if it is possible could somebody please show me how? i.e. if i click on checkbox1 it shows the text, if i click on checkbox 2 it shows the text. I managed to amend a little but when I click on any checkbox it shows all the text and not just the text for the checbox that was ticked.

Code:
Sub CheckBox1_Change()
    Call ShowHideBookmark
End Sub
 
 
Sub ShowHideBookmark()
    Dim orange As Range
    Set orange = ActiveDocument.Bookmarks("Bookmarkname").Range
    If CheckBox1.Value = True Then
        With orange.Font
            .Hidden = True
        End With
        With ActiveWindow.View
            .ShowHiddenText = False
            .ShowAll = False
        End With
    Else
        With orange.Font
            .Hidden = False
        End With
        With ActiveWindow.View
            .ShowHiddenText = True
            .ShowAll = False
    
        End With
    End If
    
End Sub
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old October 15th, 2009, 11:21 PM
Friend of Wrox
Points: 1,449, Level: 15
Points: 1,449, Level: 15 Points: 1,449, Level: 15 Points: 1,449, Level: 15
Activity: 17%
Activity: 17% Activity: 17% Activity: 17%
 
Join Date: Sep 2005
Location: , , .
Posts: 420
Thanks: 0
Thanked 14 Times in 14 Posts
Default

Hi

You can try passing the control as reference

Code:
Sub CheckBox1_Change()
    Call ShowHideBookmark(CheckBox1)
End Sub
 
 
Sub ShowHideBookmark(ByRef CB)
    Dim orange As Range
    Set orange = ActiveDocument.Bookmarks("Bookmarkname").Range
    If CB.Value = True Then
        With orange.Font
            .Hidden = True
        End With
        With ActiveWindow.View
            .ShowHiddenText = False
            .ShowAll = False
        End With
    Else
        With orange.Font
            .Hidden = False
        End With
        With ActiveWindow.View
            .ShowHiddenText = True
            .ShowAll = False
    
        End With
    End If
    
End Sub
Cheers
Shasur
__________________
C# Code Snippets (http://www.dotnetdud.blogspot.com)

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Loop over check boxes sams ASP.NET 1.0 and 1.1 Professional 5 July 17th, 2007 07:26 AM
Check Boxes Allan320 Access VBA 3 June 2nd, 2006 06:45 AM
Using check boxes to filter dstein4d Access VBA 13 January 25th, 2006 07:50 PM
Disable Check Boxes sweet4511 VB How-To 22 July 19th, 2005 04:53 PM
Using check boxes in datagrid ractim ADO.NET 2 September 8th, 2004 09:28 AM



All times are GMT -4. The time now is 12:21 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc