Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-11-2014, 05:48 AM
Squibble Squibble is offline Toggle Button Windows 7 64bit Toggle Button Office 2013
Novice
Toggle Button
 
Join Date: Jun 2014
Posts: 1
Squibble is on a distinguished road
Default Toggle Button

Hello

I've added a Bookmark to my document I am trying to create a Show/Hide, I assume A Toggle Button is best suited to this task. I have named the Toggle Button Caption "Show" and added the following code it however won't work can somebody help? It will be gratefully appreciated



Quote:
If .Togglebutton1.Caption = "Show"
ActiveDocument.Bookmarks("PreApproved").Range.Font .Hidden = False
ToggleButton1.Caption = "Hide"
Else
If .ToggleButton1.Caption = "Hide" Then
ActiveDocument.Bookmarks("PreApproved").Range.Font .Hidden = True
I have searched the internet but not having much luck.
Reply With Quote
  #2  
Old 06-11-2014, 11:58 AM
jpb103's Avatar
jpb103 jpb103 is offline Toggle Button Windows 7 64bit Toggle Button Office 2007
Advanced Beginner
 
Join Date: May 2014
Location: Thunder Bay, Ontario
Posts: 58
jpb103 is on a distinguished road
Default

You have a space between .Font and .Hidden. This should cause a syntax error. I just made something similiar myself, except I did not use a command button. I inserted a bookmark called "HelpText" and then, in the line just above the bookmark, I pressed Ctrl+F9 and inside the {} that appeared I wrote: MACROBUTTON ToggleHelp Toggle
Then I pressed Alt+F9 to activate it. The code for the ToggleHelp macro I wrote follows:
Code:
Sub ToggleHelp()
'///////////////////////////////////////////////////////////////////////////////////
'///////////////This function toggles the instructions for use//////////////////////
'///////////////////////////////////////////////////////////////////////////////////
If (ActiveDocument.Bookmarks("HelpText").Range.Font.Hidden) Then
    ActiveDocument.Bookmarks("HelpText").Range.Font.Hidden = False
Else
    ActiveDocument.Bookmarks("HelpText").Range.Font.Hidden = True
End If
'//////////////////END//////////////////////////////////////////////////////////////
End Sub
That way you just double click the word "Toggle" and it hides/shows the bookmarked block.

Last edited by jpb103; 06-11-2014 at 12:07 PM. Reason: added code
Reply With Quote
  #3  
Old 06-11-2014, 05:36 PM
macropod's Avatar
macropod macropod is offline Toggle Button Windows 7 32bit Toggle Button Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Simpler:
Code:
Sub ToggleHelp()
With ActiveDocument.Bookmarks("HelpText").Range.Font
  .Hidden = Not .Hidden
End With
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Toggle Button Macro to toggle outline level Jennifer Murphy Word VBA 3 01-22-2014 11:22 PM
Toggle Button Toggle objects on / off with custom toolbar Milon Word VBA 3 07-23-2013 06:21 AM
Macro to toggle outline level Jennifer Murphy Word VBA 0 07-08-2013 08:20 AM
Toggle Button Toggle Merge Field Code Help Please tonywatsonmail Mail Merge 2 08-11-2011 07:06 AM
Toggle updates dbugosh Office 2 12-16-2010 07:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:48 AM.


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