Userform controls mapped to document controls in word 07?

S

sarahj

I'm not sure if I'm even asking this question properly. I have a couple of
things I want:

I want to have a userform that collects data (done)
When the user clicks a button on the userform I want the data to populate at
certain points in the document (done, but with bookmarks).
I want to use the OpenOffice XML mapping of controls to XML.
Is there a way to, instead of inserting the data before/after a bookmark in
the document, populate controls in the document with data collected on a
userform?
Thanks for your help!
 
G

Greg Maxey

There are several ways fo pointing to ContentControls in a document with
VBA. Here is one:

Private Sub CommandButton1_Click()
With ActiveDocument
.SelectContentControlsByTitle("Name").Item(1).Range.Text =
Me.TextBox1.Text
.SelectContentControlsByTitle("Age").Item(1).Range.Text = Me.TextBox2.Text
End With
Me.Hide
End Sub


Assumes you have a control titled "Name" and one titled "Age" a userform
with two textboxes and a command button.

This has really nothing to do with XML mapping. You could map the controls
when you create them. See:
http://gregmaxey.mvps.org/Mapped_Content_Control.htm
 
S

sarahj

I actually found your page after posting this and started using your toolbar
for mapping controls to xml and it helped me get that piece done perfectly.
Additionally though, I need the userform to populate those 07 controls in
the document. Is there a way to get the userform controls to populate the 07
controls? Would I use the xml name for each control in the document?
 
G

Greg Maxey

I don't really understand your question/issue. If you have a ContentControl
named say "ClientName" and it is mapped to six other controls then if you
populate one in the document then all should update with the data entered.
If you populate one with a userform then all should reflect the same data.
 

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