Working with "Default text" in a Word doc. Form Text field
- From: RG <RG@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 3 Apr 2008 08:21:00 -0700
Hello. We’re trying to create a VB application (using .NET 2003) that opens
a formatted Word document, places values from a SQL Server database into Form
fields in the doc (Text fields and Checkbox fields), and then allows the user
to update them. Upon saving, we intend to save the data back in the SQL
Server database.
For the step of placing initial default values into the Form fields, I’ve no
problem doing it for the Checkbox fields with these statements:
oDoc.FormFields.Item("CheckMale").CheckBox.Default = True
oDoc.FormFields.Item("CheckFemale").CheckBox.Default = False
[Note: oDoc = oWord.Documents.Open("C:\test.doc") ]
My question is: I can’t figure out how to set the “Default text” of the Text
Form fields. From an example we found we see how to set a value in the Text
field, such as:
oDoc.FormFields.Item("TextPhone").Range.Text = "555-555-5555"
However we noticed that upon doing so, the Bookmark known as "TextPhone"
disappears as an object, and you can no longer work with it in the VB code.
Therefore we want to set the “Default text” equal to some value.
When you double-click on the Text Form field in unprotected mode you can see
in the “Text Form Field Options” dialog that “Default text” is there, along
with Entry macro, Exit macro, Help text, etc. Looking around the Object
browser, I can see how I could set those other fields (which I don’t care
about), like:
oDoc.FormFields.Item("TextPhone").EntryMacro = "xxx"
oDoc.FormFields.Item("TextPhone").ExitMacro = "xxx"
oDoc.FormFields.Item("TextPhone").HelpText = "xxx"
But where’s “Default text”? The success of this design hinges on this, and
I can’t believe it simply can’t be done.
We’d appreciate any insight anyone has. Thanks.
.
- Follow-Ups:
- Next by Date: Re: Working with "Default text" in a Word doc. Form Text field
- Next by thread: Re: Working with "Default text" in a Word doc. Form Text field
- Index(es):
Relevant Pages
|