Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Feb 2001
    Location
    Toronto, Ontario, Canada
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Toggle Buttons with VBA (Word 2000)

    I am trying to have one button replace another. When button1 is clicked, some text is deleted. When button2 is clicked, the text is restored. I want to add the button replacement to the click event. It seemed simple. Both buttons are the same size and in the same position on the doc. So all the code has to do is move the top button to the bottom so the bottom button seems to replace it. Then when the button now on the top is clicked, it's moved to the bottom. But the macro fails on the ToggleFormsDesign line. Without that line, the button cannot be selected:

    Private Sub DeleteEnclLines_Click()

    If ActiveDocument.ProtectionType = wdNoProtection Then
    Else
    ActiveDocument.Unprotect
    End If

    Do stuff

    ActiveDocument.ToggleFormsDesign
    ActiveDocument.Shapes("Control 4").Select
    Selection.ShapeRange.ZOrder msoSendToBack
    ActiveDocument.ToggleFormsDesign

    ActiveDocument.Protect (wdAllowOnlyFormFields), NoReset:=True

    End Sub

    Maybe there's a better way?

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

    Re: Toggle Buttons with VBA (Word 2000)

    Why not use one button, and change the caption depending on the situation, and use an If statement to execute one or the other action?

  3. #3
    Lounger
    Join Date
    Feb 2001
    Location
    Toronto, Ontario, Canada
    Posts
    44
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Toggle Buttons with VBA (Word 2000)

    Hans,
    Thank you. Always right on point.

Posting Permissions

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