S
sweetguy1only
Hi all,
I am using VBA to create MS Access applications. When my clients get
the application, they are only getting the Access run-time; they
don't
need the full version of Access in order to run the application. The
problem that I am having with is, I am using VBA to do a mailmerge
from a recordset in Access to a new word document or existing word
document. This feature works on most of my cleints' machines.
However, for certain clients, when the word document comes up, the
Insert Merge Fields option in the Mail Merge Toolbar would be greyed
out. For these clients that are having problem, they are all using
Windows XP Professional with MS Word 2003. The weird thing is, I
have
Windows XP Professional with MS Word 2003 too but it works for me
every single time. My codes are as follows, can anyone give me some
pointers on how to correct the problem please?
Thanks in advance,
Monte
Set WordApp = CreateObject("Word.Application")
If stMergeDoc = "" Then 'Create a new Word doc
Set WordDoc = WordApp.Documents.Add
Else 'Open the word document selected by the user
Set WordDoc = WordApp.Documents.Open(stMergeDoc)
'Set objWord = GetObject(stMergeDoc, "Word.Document")
End If
WordApp.Visible = True
'objWord.Application.Visible = True
WordDoc.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="QUERY " & stMergeSrc, _
SubType:=wdMergeSubTypeWord2000
'SQLStatement:=strSQL
If Err.Number = 448 Then 'they have word 2000, so try again
without the subtype argument
WordDoc.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="QUERY " & stMergeSrc
End If
I am using VBA to create MS Access applications. When my clients get
the application, they are only getting the Access run-time; they
don't
need the full version of Access in order to run the application. The
problem that I am having with is, I am using VBA to do a mailmerge
from a recordset in Access to a new word document or existing word
document. This feature works on most of my cleints' machines.
However, for certain clients, when the word document comes up, the
Insert Merge Fields option in the Mail Merge Toolbar would be greyed
out. For these clients that are having problem, they are all using
Windows XP Professional with MS Word 2003. The weird thing is, I
have
Windows XP Professional with MS Word 2003 too but it works for me
every single time. My codes are as follows, can anyone give me some
pointers on how to correct the problem please?
Thanks in advance,
Monte
Set WordApp = CreateObject("Word.Application")
If stMergeDoc = "" Then 'Create a new Word doc
Set WordDoc = WordApp.Documents.Add
Else 'Open the word document selected by the user
Set WordDoc = WordApp.Documents.Open(stMergeDoc)
'Set objWord = GetObject(stMergeDoc, "Word.Document")
End If
WordApp.Visible = True
'objWord.Application.Visible = True
WordDoc.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="QUERY " & stMergeSrc, _
SubType:=wdMergeSubTypeWord2000
'SQLStatement:=strSQL
If Err.Number = 448 Then 'they have word 2000, so try again
without the subtype argument
WordDoc.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="QUERY " & stMergeSrc
End If