Results 1 to 4 of 4
  1. #1
    Kevan
    Guest

    clear Textboxes

    I have a word document with many textboxes. I would like to clear the text boxes with a command button.

    I have done this in vb with code that looks like this but it does not seem to work in word. I tried to modify it using shapes rather than control but with no luck,

    Private Sub CommandButton1_Click()
    Dim ctl As Control

    'Clear all the TextBoxes.
    For Each ctl In ThisDocument.Controls
    If TypeOf ctl Is TextBox Then
    ctl = ""
    End If
    Next

    End Sub

    Any help would be appreciated
    Kevan

  2. #2
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: clear Textboxes

    Hi Kevan,

    The quickest answer is to point you to the VBA Help topic "Using ActiveX controls on Word documents".

    Controls added from the Controls Toolbox can be either inline shapes or shapes, depending on how they are added.

    Hope this helps,
    Gary

  3. #3
    2 Star Lounger
    Join Date
    Mar 2001
    Location
    Oregon, USA
    Posts
    129
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: clear Textboxes

    Hi Kevan,

    Perhaps the following adapted from VBA help?

    Dim tb

    For Each tb In ActiveDocument.Shapes
    With tb.TextFrame
    .TextRange.Text = ""
    End With
    Next

    HTH,

    Chris

  4. #4
    Kevan
    Guest

    Re: clear Textboxes

    Unfortunately I was unable to solve the problem. Thanks to Gary and Chris for you help. I will continue to search and I will post the solution when I find it.

Posting Permissions

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