Inserting responses from form to Word document

G

Gerry

I've created a form to capture responses to be inserted
into a Word document (many thanks to Dian Chapman and her
articles). Now I need to know how to open Word through ADO
and VB.

Any help?
 
G

Guest

-----Original Message-----
I've created a form to capture responses to be inserted
into a Word document (many thanks to Dian Chapman and her
articles). Now I need to know how to open Word through ADO
and VB.

Any help?
.
Include reference to OLE Automation in your VB
projects 'References'

Set oWord = CreateObject("Word.Application")
'Assuming that you have created word Bookmarks at the
appropirate location within the Word Document (Template)

With oWord
' Make Word visible if you want to do so
.Visible = True
' Open Template file
.documents.Open ("C:\My Documents\Any.dot")
' Output data from VB form
.ActiveDocument.Bookmarks("Bm1").Select
.Selection.TypeText frmText1.Text
.Selection.TypeParagraph
' next output from form
.ActiveDocument.Bookmarks("Bm2").Select
.Selection.TypeText frm.textbox2.text
Wend
 

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