Using forms to populate fields in a document

K

Kirrlz

Hi,

I'm not sure if this can be done but I have made a form and would like to
use the text entered into the text fields to populate fields throughout the
document.

eg. A field 'Company Name' on a form, which when the user inputs their
company name - say 'Microsoft' the word 'Microsoft' appears in all fields set
to be a company name field throughout the rest of the document.

Please let me know what the best way to go about this would be, I dont even
know where to start!

Thanks,

Kirrlz
 
D

Doctorjones_md

This seems to work well --

You have your document (in this case -- TirePressureCheck.doc)

1. You open VBE and add a UserForm1

2 Add a ListBox1 and CommandButton1 to your form

The code for these objects are as follows:

Private Sub CommandButton1_Click()

With ActiveDocument
.Bookmarks("Report_Number").Range _
.InsertBefore TextBox1
.Bookmarks("Date").Range _
.InsertBefore TextBox2
.Bookmarks("Location").Range _
.InsertBefore TextBox3
.Bookmarks("Spool_Details").Range _
.InsertBefore TextBox4
.Bookmarks("Pump_Pressure").Range _
.InsertBefore TextBox5
.Bookmarks("Name1").Range _
.InsertBefore ComboBox1.Text
.Bookmarks("Name2").Range _
.InsertBefore ComboBox1.Text
.Bookmarks("Name3").Range _
.InsertBefore ComboBox1.Text
End With

UserForm1.Hide
End Sub

Private Sub UserForm_Initialize()
With ComboBox1
.AddItem "George Foreman"
.AddItem "Archie Bunker"
.AddItem "Alan Greenspan"

End With

End Sub


HTH
 

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