Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

manipulate Word object programatically

Status
Not open for further replies.

lespaul

Programmer
Feb 4, 2002
7,083
US
I have a Word template that has a text box in the footer. This template is called from a Delphi application which uses form fields to populate database information into the document. I need to be able to hide the text box (or delete it if that's an option) when a certain condition is true.

How do I find the object name in order to programatically refer to it? I've opened the VBA editor and tried to find the object inspector to "see" a list of all the objects on the document but can never see anything!

Does a text box have a visibility flag that I can set?

Any suggestions appreciated.

Thanks!

Leslie

Come join me at New Mexico Linux Fest!
 


Hi,

From your description, it seem like you might have a FormField.
Code:
For Each aField In ActiveDocument.FormFields
    If aField.Type = wdFieldFormTextInput Then Count = Count + 1
Next aField


Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
sorry, try this...
Code:
    Dim aField As FormField
    For Each aField In ActiveDocument.FormFields
        If aField.Type = wdFieldFormTextInput Then
            MsgBox aField.Name
        End If
    Next aField

Skip,
[glasses]Don't let the Diatribe...
talk you to death![tongue]

[glasses]Just traded in my old subtlety...
for a NUANCE![tongue]
 
Does a text box have a visibility flag that I can set?"

No. There is no Visible property for any object in the document, be it a formfield, or an ActiveX control.

BTW: it helps if you tell us specifics. As Skip points out, it sounds like a text formfield...EXCEPT footers can not have formfields in them.

So, if it is in the footer, then it is not a formfield.

Is it an ActiveX textbox (from the Controls toolbar)?

BTW2: if it is is an ActiveX textbox (in the footer or otherwise) you CAN see it as a object in the left dropdown of the ThisDocument code module.

Gerry
 
Ok sorry for the delay in my response...i've been out sick.....yes the template itself has form fields but the one piece of information I am trying to "toggle" off and on is a text box and it is in the footer....So if you have the Draw menu at the bottom of word when it opens there's the line, arrow, rectangle, circle, and 'text box' - that's the one I've used in the footer....

Can I look through the items in the footer and if my test if true change the font color to white so it's just a blank text box?

Leslie
 
You may consider the HeaderFooter.Shapes collection.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top