Results 1 to 5 of 5
  1. #1
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Word VBA newbie textbox question (2000SP3)

    Can't seem to find the answer in online help/mvp sites/web searches. Most annoying thing is that I had solved this problem but the macro got lost in normal.dot when I reinstalled.

    All I want to do is cycle through all the text boxes in a document and change the back style to transparent, but I can't seem to find the right syntax. Text boxes do seem to be shapes (although in online help they are only spoken of as controls), but I can't seem to find a "shapetype" property, and AutoShapeType doesn't list textbox as a possible value. Looking through the controls collection, however, there don't seem to be any potential properties that will allow me to do what I'd like to do.

    So I'd be very grateful if someone could correct this code:

    Dim shp as Shape
    For Each shp in ActiveDocument.Shapes
    If shp.type=textbox then shp.BackStyle=fmBackStyleTransparent
    Next shp

    Thanks

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

    Re: Word VBA newbie textbox question (2000SP3)

    The Type of a text box is msoTextBox (a symbolic constant with value 17), so you can use

    If shp.Type = msoTextBox Then ...

  3. #3
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Word VBA newbie textbox question (2000SP3)

    Thanks Hans,

    Still can't find it in help.

    Now I find that shapes are not objects, so my method for setting the back style to be transparent doesn't work. I've been through all the properties of a shape, and tried creating a text box and setting it's fill to nofill and see which properties change, but to no avail.

    So how can I set the fill of the textbox to no fill?

    Don't know why this is proving so difficult - is it me or is word vba help considerably less helpful than that for access or excel?

    Thanks

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

    Re: Word VBA newbie textbox question (2000SP3)

    If you don't know what code to use, recording a macro may help. It turns out to be shp.Fill.Visible = False.

    Dim shp As Shape
    For Each shp In ActiveDocument.Shapes
    If shp.Type = msoTextBox Then
    shp.Fill.Visible = False
    End If
    Next shp
    Set shp = Nothing

  5. #5
    3 Star Lounger
    Join Date
    Feb 2001
    Posts
    369
    Thanks
    2
    Thanked 1 Time in 1 Post

    Re: Word VBA newbie textbox question (2000SP3)

    Thanks Hans,

    It's been too long since I've done this - completely forgot about recording a macro.

    Don't know how I missed this when going through all the properties.

    Sorry for wasting your time, and many thanks.

Posting Permissions

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