• Toggle Buttons with VBA (Word 2000)

    Author
    Topic
    #424429

    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?

    Viewing 0 reply threads
    Author
    Replies
    • #974685

      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?

    Viewing 0 reply threads
    Reply To: Toggle Buttons with VBA (Word 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: