Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Efficient Code (Word 2000/2003)

    I want to turn on/off hidden text. Recording the macro results in the following:

    Application.DisplayStatusBar = True
    Application.ShowWindowsInTaskbar = True
    Application.ShowStartupDialog = True
    With ActiveWindow
    .DisplayHorizontalScrollBar = True
    .DisplayVerticalScrollBar = True
    .DisplayLeftScrollBar = False
    .StyleAreaWidth = InchesToPoints(0)
    .DisplayVerticalRuler = True
    .DisplayRightRuler = False
    .DisplayScreenTips = True
    With .View
    .ShowAnimation = True
    .Draft = False
    .WrapToWindow = False
    .ShowPicturePlaceHolders = False
    .ShowFieldCodes = False
    .ShowBookmarks = True
    .FieldShading = wdFieldShadingWhenSelected
    .ShowTabs = False
    .ShowSpaces = False
    .ShowParagraphs = False
    .ShowHyphens = False
    .ShowHiddenText = False
    .ShowAll = False
    .ShowDrawings = True
    .ShowObjectAnchors = False
    .ShowTextBoundaries = False
    .ShowHighlight = True
    .DisplayPageBoundaries = True
    .DisplaySmartTags = True
    End With
    End With
    End Sub

    Isn't there a 1 or 2 line code that will also work?

    I tried:

    ActiveWindow.View.ShowHiddenText

    but received an "invalid use of property" error.

    Thank you,

  2. #2
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Efficient Code (Word 2000/2003)

    Looks as though ActiveWindow.View.ShowHiddenText = True/False is the one property you need to toggle. Word's macro recorder usually spells out everything in a dialog when you touch it. This is good for discovery, but messy for deployment. (And you really miss it when it doesn't happen!)

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Efficient Code (Word 2000/2003)

    The macro recorder actually records all the settings in the View tab of Tools | Options..., instead of only the one you modified. Here is a macro that toggles the display of hidden text:

    Sub ToggleHidden()
    With ActiveWindow.View
    .ShowHiddenText = Not .ShowHiddenText
    End With
    End Sub

    If you only want to turn it on, replace Not .ShowHiddenText by True, and if you want to turn it off, by False.

  4. #4
    2 Star Lounger
    Join Date
    Jul 2003
    Location
    Park City, Utah
    Posts
    189
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Efficient Code (Word 2000/2003)

    Thank you once again. I like the Toggle option since it will be placed on a toolbar button.

  5. #5
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Yilgarn region of Toronto, Ontario
    Posts
    5,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Efficient Code (Word 2000/2003)

    Here's my ShowAll macro, installed as a toolbar button, replacing MSWord's backward (in both sense of the word) letter-P tool.

    <pre>Public Sub ShowAll()
    'The setting ShowFieldCodes will be used to control the settings of ShowFieldCodes, ShowAll ,
    ' ShowFieldCodes , ShowHiddenText , ShowTabs , ShowSpaces , ShowParagraphs and ShowBookmarks.
    'All flags will be set to the opposite of the current setting of ShowFieldCodes.
    'If ShowFieldCodes is ON, all flags will be set OFF.
    'If ShowFieldCodes is OFF, all flags will be set ON.

    Dim boolSet As Boolean
    boolSet = Not ActiveWindow.View.ShowFieldCodes
    With ActiveWindow.View
    .ShowAll = boolSet
    .ShowFieldCodes = boolSet
    .ShowHiddenText = boolSet
    .ShowTabs = boolSet
    .ShowSpaces = boolSet
    .ShowParagraphs = boolSet
    .ShowBookmarks = boolSet
    End With
    End Sub
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •