Connecting Tech Pros Worldwide Forums | Help | Site Map

Opening a mail doc from Access - code problem

Andy Davis
Guest
 
Posts: n/a
#1: Nov 13 '05
Hi

I've written the following code for a button on a form to open a mail merge
document in MS Word. The code opens the document fine but does not display
the usual connection details to open the table in my database when the file
is opened.i.e:
"Opening this document will run the following SQL command:
SELECT * FROM 'filename' "
Hence all that is opened is a document with no updated details from the
source table. If I open the document directly in Word it works OK.

-----------------------------------
VBA Code in Access form:

On Error GoTo Err_SettLett_Word_Click
'declare variables
'object variable that refers to Word
Dim appWord As Object

'Word.Application data type established from reference to Word's object
library
Set appWord = CreateObject("Word.Application")
'make Word visible
appWord.Visible = True

'Open Word document
With appWord
.Documents.Add "C:\DD\Database work\GCRE\settlement_lett.doc"
End With

----------------------------------

Any help much appreciated.

Thanks in advance

Dawn



Donbyrne
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Opening a mail doc from Access - code problem


I found your question while trying to find an answer to the same
thing. I could not find much in the way of help for the linking to
the table or query from the word document. All solutions came to the
same result. It only opened the document.

I played with another example and found that this works

Dim retVal
retVal = Shell("WINWORD.EXE " & varFolder &
"Documents\NewsletterLabel.doc", vbMaximizedFocus)


I hope it helps you.

Don Byrne

Closed Thread


Similar Microsoft Access / VBA bytes