View Single Post
  #1 (permalink)  
Old July 9th, 2004, 07:59 AM
william.murray william.murray is offline
Authorized User
 
Join Date: Jun 2004
Location: Boness, Falkirk, United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access automation

Hi - I was wondering if someone could help me? I'll start at the begining: I need a user to open a word document (from Access) which has some static text(mail merge) and I need to append data from a form to it. This isn't a problem I've used the basic code shown in the automation chapter (sorry at work and can't remember the chapter nr) with some slight modifications - API call to CMDLG32.dll assigning the file name to a string and passing the string to the getobject function as a parameter. Now the problem starts I get 2 word documents opened, the merge template document and another "Formdocument" both with the same info? Is it possible only to open the new document with all the staic and dynamically assigned text?

Code snippit below. (Be kind to me I'm new to this game ;o))

Private Sub CmdGetCmnDlg_Click()
On Error GoTo Err_CmdGetCmnDlg_Click

Dim strPath As String
Dim WordDoc As Word.Document

strPath = GetFile

If (strPath = "") Then
  Exit Sub
Else

Set WordDoc = GetObject(strPath)
WordDoc.Application.Visible = True

WordDoc.MailMerge.OpenDataSource *****...................etc
WordDoc.MailMerge.Execute

Cheers Wullie

William
__________________
William