Pasting Combobox Value in Current Cell

J

Jim

I followed the instructions in the Knowledge Base Article
306258 (How to Create a Combo Box Containing More Than 25
Items). I want to use the same UserForm I created to
display different choices in a number of cells in my Word
protected form.

How do I change the following code:

ActiveDocument.FormFields("Text1").Result=ComboBox1.Value

so that the ComboBox value will paste in the current cell
selected instead of at the Text1 bookmark in the KB
example?

Any assistance is greatly appreciated.
 
P

Peter Hewett

Hi Jim

Lets get this straight. Your using a protected document with a table that contains
FormFields. I'm presuming you actually want to insert the UserForms ComboBox control
contents into the current TextInput field? You say <cell>, but a table cell can contain
more than one FormField hence the clarification..

This will update the current FormField with the contents of the ComboBox control:

Public Sub UdateFFUsingComboBox()
GetCurrentFF.Result = ComboBox1.Value
End Sub

Private Function GetCurrentFF() As Word.FormField
With Selection
If .FormFields.Count = 1 Then

' CheckBox or DropDown
Set GetCurrentFF = .FormFields(1)

ElseIf .FormFields.Count = 0 And .Bookmarks.Count > 0 Then
Set GetCurrentFF =
ActiveDocument.FormFields(.Bookmarks(.Bookmarks.Count).Name)
End If
End With
End Function

HTH + Cheers - Peter
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Jim > écrivait :
In this message, < Jim > wrote:

|| I followed the instructions in the Knowledge Base Article
|| 306258 (How to Create a Combo Box Containing More Than 25
|| Items). I want to use the same UserForm I created to
|| display different choices in a number of cells in my Word
|| protected form.
||
|| How do I change the following code:
||
|| ActiveDocument.FormFields("Text1").Result=ComboBox1.Value
||
|| so that the ComboBox value will paste in the current cell
|| selected instead of at the Text1 bookmark in the KB
|| example?
||
|| Any assistance is greatly appreciated.

Did you see the answer I posted 5 days ago to the exact same question you
posted in the userform group?

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
J

Jean-Guy Marcil

Bonjour,

Dans son message, < Jim > écrivait :
In this message, < Jim > wrote:

|| Many thanks Jean-Guy. I now have the template working as
|| it should.

Glad I could help!

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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