Send Access Data to Word (not mailmerge)

F

Feaglet

:confused: I need to send specific fields to ms word to create a letter
and then create subsequent letters based on the same record. As you can
see a mail merge will not work (I think).

I can do the above as long as word is closed. The problems arises when
I try the above with word open.

I am using 'sendkeys' to create the letter but if word is already open
then odd things start happening almost like the code is too quick for
the commands. I tried adding a 'stop and wait' piece of code after I
open word but when I try insert a page break it inserts a URL ?????

SendKeys "%i", True
SendKeys "{ENTER 2}"

in word 'ALT i and cariage return twice' this will place a page break
in.
As I mentioned - this works fine the first time round - so am I
accessing word incorrectly or what? Code below.

Help Needed and appreciated

Filename = Trim((Record_Name) & ".doc") 'Filename holds the file name
string
FileLocation = Dir(CStr("c:\folder_name\") & Filename)

If FileLocation = (Filename) Then 'if the file exists
FileLocation = (CStr("c:\folder_name\") & Filename)
Set worddoc = GetObject(FileLocation)
Set Objword = worddoc.Application
Objword.Documents.Open (FileLocation)
Objword.Visible = True
SendKeys "^{END}", True 'end of page
SendKeys "%i", True 'page break
SendKeys "{ENTER 2}", True
 

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