Wrox Programmer Forums
|
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 Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 5th, 2009, 05:05 AM
Registered User
 
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
 
Old October 15th, 2009, 10:21 PM
Friend of Wrox
 
Join Date: Sep 2005
Posts: 812
Thanks: 1
Thanked 53 Times in 49 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)





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 06:26 AM
Check Boxes Allan320 Access VBA 3 June 2nd, 2006 05: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 03:53 PM
Using check boxes in datagrid ractim ADO.NET 2 September 8th, 2004 08:28 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.