View Single Post
  #3   Report Post  
Posted to microsoft.public.word.mailmerge.fields
 
Posts: n/a
Default Using macro, mail merge, access

I am using Word 2003 and Access 2003

Here is my VBA code in Access. This opens the file I want.

Me.Visible = False
DoCmd.OpenQuery "Selected Record"

Dim objWord As Object
Set objWord = CreateObject("Word.Application")
objWord.Visible = True
objWord.Documents.Open
"x:\technicians\training\rca\RCA_Form_v.1.doc/mMacro1


I still have to run the Macro manually. Once the macro runs there is a
screen that you have to select the data source. I click "Machine Data
Source" then click MS Access Database then OK. Then it prints out as
the macro says.

Here is the Macro VB

Sub Macro1()
'
' Macro1 Macro
' Macro recorded 12/7/2005 by jasbax
'
ActiveDocument.MailMerge.OpenDataSource Name:= _
"C:\Documents and Settings\jasbax\My Documents\My Data
Sources\Root Cause Analysis Updated Record Selection.odc" _
, ConfirmConversions:=False, ReadOnly:=False,
LinkToSource:=True, _
AddToRecentFiles:=False, PasswordDocument:="",
PasswordTemplate:="", _
WritePasswordDocument:="", WritePasswordTemplate:="",
Revert:=False, _
Format:=wdOpenFormatAuto, Connection:= _
"Provider=MSDASQL.1;Persist Security Info=False;Data Source=MS
Access Database;Extended Properties=""DSN=MS Access
Database;DBQ=X:\Technicians\Training\RCA\Root Cause
Analysis.mdb;DefaultDir=X:\Technicians\Training\RC A;DriverId=25;FIL=MS
Access;MaxBufferSiz" _
, SQLStatement:="SELECT * FROM `Updated Record Selection`",
SQLStatement1 _
:="", SubType:=wdMergeSubTypeOther
ActiveDocument.MailMerge.ViewMailMergeFieldCodes = wdToggle
ActiveDocument.PrintOut
End Sub