from listbox to formfield...

N

natanz

I am still working on moving data from a spreadsheet to a word file (a
document created from a template). I have successfully gotten the data
into a listbox, but now i am having trouble moving the selection into
the right place on the document. I have the following code as a click
event of the userform.

Private Sub CommandButton1_Click()
Dim projnum As String

projnum = ListBox1.Text
ActiveDocument.FormFields("text19").Result = projnum
UserForm1.Hide
MsgBox projnum

End Sub

I put the msgbox in there to see if anything was being transferred to
my variable but it looks like nothing is. Can anyone help me with what
i am doing wrong here?

i feel like it should not be significant but the template is a
protected form, where "text19" is a textbox form field.
 
D

Doug Robbins

Use

ListBox1.Value

but you need to make sure that the data you want is in the BoundColumn of
the listbox.

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 

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