How can I use a combo box to populate text field in Word 2007?

T

Thomas Mallié

Hi all,

I'm busy creating a Word 2007 template for a technical procedure for my
company.
On the first page, I've inserted a combo box with the four confidentiality
values in use for our procedures (Highly confidential, Confidential,
Restricted and Public).

I'd like the value chosen in this combo box to be repeated in the header of
the following section. But I do not find a way to link a field in the header
to the combo box on the first page and auto update when a value is chosen in
that combo box.

Is this possible?

Tx in advance
 
G

Greg Maxey

Perhaps you could put a bookmark in the following section header e.g.,
Sect2Class and then use the ComboBox change event:

Private Sub ComboBox1_Change()
Dim oRng As Word.Range
Set oRng = ActiveDocument.Bookmarks("Sect2Class").Range
oRng.Text = Me.ComboBox1.Value
ActiveDocument.Bookmarks.Add "Sect2Class", oRng
End Sub

Hi all,

I'm busy creating a Word 2007 template for a technical procedure for
my company.
On the first page, I've inserted a combo box with the four
confidentiality values in use for our procedures (Highly
confidential, Confidential, Restricted and Public).

I'd like the value chosen in this combo box to be repeated in the
header of the following section. But I do not find a way to link a
field in the header to the combo box on the first page and auto
update when a value is chosen in that combo box.

Is this possible?

Tx in advance

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org


McCain/Palin '08 !!!
 
T

Thomas Mallié

Hi Greg,

thanks for your answer, but could you detail where I have to put that code?
I don't know how it works with Word 2007.

cheers
 
G

Graham Mayor

For the creation of Word forms, the new content controls in Word 2007, in my
opinion, leave a lot to be desired. Personally I would use the legacy form
fields and create a dropdown box for your entries and use a REF field to
reproduce the content. REF fields in page headers do not update
automatically, but you can use the update macro at
http://www.gmayor.com/installing_macro.htm to force an update run on exit
from the dropdown field.

If you decide to follow this route, Greg has an add-in that makes the use of
legacy form fields much more accessible in Word 2007 -
http://gregmaxey.mvps.org/Classic Form Controls.htm and has more
information on repeating text - http://gregmaxey.mvps.org/Repeating_Data.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP

My web site www.gmayor.com

<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
G

Greg Maxey

Thomas,

By your use of "ComboBox" and no mention of a userform I assumed that you
were using an ActiveX combobox in the document. In view of Graham's post
and your separate message to me, it appears that you want to use a Dropdown
ContentControl.

While I am not as put off with CCs as my old pal Graham, they do have their
quirks but in this case I think the following code (in the ThisDocument
module) will work:

Private Sub Document_ContentControlOnExit(ByVal CC As ContentControl, Cancel
As Boolean)
Dim oRng As Word.Range
Select Case CC.Title
Case Is = "DocStatus" 'the title of your CC Dropdown.
If CC.Range.Text <> "Choose an item." Then
Set oRng = ActiveDocument.Bookmarks("Sect2Header").Range 'You need to
put a bookmark in the section 2 header named "Sect2Header"
oRng.Text = CC.Range.Text
ActiveDocument.Bookmarks.Add "Sect2Header", oRng
Else
Set oRng = ActiveDocument.Bookmarks("Sect2Header").Range
oRng.Text = ""
ActiveDocument.Bookmarks.Add "Sect2Header", oRng
End If
Case Else
'Do nothing
End Select
End Sub


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org


McCain/Palin '08 !!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top