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

    .ShowFieldCodes ' doesn't work? (Word97SR2/VBA)

    My ShowAll macro works fine. Today I can't get working a simple macro to force the display of field codes ON.

    <pre>Sub Macro1()
    With ActiveWindow
    With .View
    ' .ShowFieldCodes = True ' doesn't work?
    ' .ShowAll = True ' always works
    End With
    End With
    ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes ' doesn't work?
    End Sub
    </pre>

    In the example above, the toggle, taken from VBA Help files, seems not to work at all. No matter how often I run it, I never see field codes.

    If I suspend that statement and activate the ShowAll, that works first time, every time, all the time.

    If instead I swing the .ShowFieldCodes=TRUE into action, it never seems to work.

    Why?


    I would have thought that setting .ShowFieldCodes to true was about as simple as it could get.

    I'd appreciate any feedback from other Word97 users who, like me, can't make ShowFiledCodes stick.

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: .ShowFieldCodes ' doesn't work? (Word97SR2/VBA)

    Chris,

    Not sure what exactly you want , but ActiveWindow.View.ShowFieldCodes = True (=Alt-F9) should set tthe field codes View to On and leave it that way unless you change it. You can set the Field codes view to ON as the default in Tools, Options, View.

    In Word 97 both the following toggle nicely :<pre> With ActiveWindow.View
    .ShowFieldCodes = Not .ShowFieldCodes
    End With

    With ActiveWindow.View
    .ShowAll = Not .ShowAll
    End With</pre>


    The following should keep them im sync :<pre> With ActiveWindow.View
    .ShowFieldCodes = Not .ShowFieldCodes
    .ShowAll = .ShowFieldCodes
    End With</pre>


    Andrew C

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

    Re: .ShowFieldCodes ' doesn't work? (Word97SR2/VBA)

    Thanks Andrew, I'll give this a try.

    I wanted to force the display of Field Codes wheteher or not the user had it on, and restore the preserved setting at the end of my work.


    "Watch the screen!", I want to say, "and you'll see the {private} being replaced in every document". A flashing-lights sort of thing.

    I didn't want to mess around with any other settings, which is why I was averse to the .ShowAll area. (If you're with a client who needs to see flashing lights, you don't want to leave fingerprints, right?)

    I found it odd that telling Word FieldCodes ON didn't seem to make a whit of difference to anything at all on the display.

    Anyway, I'll try your method; thanks again.

  4. #4
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: .ShowFieldCodes ' doesn't work? (Word97SR2/VBA)

    Strange, this works fine for me!

    What happens if you just type

    <pre> ActiveWindow.View.ShowFieldCodes = True
    </pre>


    In the VBA immediate window?

    StuartR

  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: .ShowFieldCodes ' doesn't work? (Word97SR2/VBA)

    >In the VBA immediate window?

    I see Field Codes!



    Ahah (puts VBE Windows brain in gear - where's Kevin when we need him?) maybe when I run my macro FROM WITHIN a VBE window (as in tapping the F5-RUN key) , it looks at the window - the VBE window - rather than a document window (runs off to experiment a bit more ....)

  6. #6
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Dublin, Ireland, Republic of
    Posts
    2,697
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: .ShowFieldCodes ' doesn't work? (Word97SR2/VBA)

    <looks at the window - the VBE window - rather than a document window >,

    I think not.

    Activewindow is a property of the Application, in this case Word.

    Andrew

Posting Permissions

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