pass values from Access to Word doc

  • Thread starter Thread starter ruomingxu via AccessMonster.com
  • Start date Start date
R

ruomingxu via AccessMonster.com

I am new in this area. I want to use values in a Access database and pass
them to a word document. I tried this test code in a form of the Access
database but it didn't work (temp.doc is a word doc already stored in C:
drive):

Dim oX As Object
Set oX = CreateObject("C:\temp.doc")
oX.editreplace "<<FirstName>>", "Richard", 0, 1, 0, 0, 0, 0, 0, 1, 0, 0, 0
oX.Application.Visible = True
Set oX = Nothing
End Sub

It returns an error message something like "The object doesn't support this
property" (it stops at 3rd line in the above code). I know I must have
missed something, but don't know what it is. Any help is appreciate it.

Richard
 
you have to add a reference to MS word and then create an object of
word to do your operation

That is if u haven't already done so
 
roader,

I did add a Microsoft Word 10.0 Object Library. Sitll not working. But I
don't know how to create an object of word. Can you help with codes?

Thanks. Appreciate your help.

Richard
 
hi

declare
dim appword as new word.application

in an event or sub

appword.documents.open(filename)




If u want to know more about these and other methods download this file
from MS website ( vba for word)

http://www.microsoft.com/downloads/...82-E6E6-4B78-AFF9-9A541167541F&displaylang=en

That is office 2003 ...If u are using an older version search for it

Now probably the file is already in your computer....in the same folder
where word is installed...So check all the .chm files in that folder

Whenever u call a method just prefix it with your word object ...in
this case appword
 
roader,

Thanks for your tip. I will check it out.

Richard
 

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

Back
Top