
Signature
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
>I have a over 400 mailmerge document in Word 2003. My
> access program automates a mail merge process and prints
[quoted text clipped - 8 lines]
> merged, printed, then closed without user
> intervention. Thanks.
I am doing what you suggested. See my code that follows:
With rsTemplates
Do Until .EOF
Set rsTempDocs = db.OpenRecordset("Select
TemplateDescription, TemplateFilename From
Template_Matrix Where TemplateCode = " & Chr(34) &
rsTemplates!Template & Chr(34), dbOpenSnapshot)
'Test to see if TemplateFilename is valid
else move all records with this templatecode, error
message missing word document, Call Programmer
'remove records and continue processing if at
least one record remaining
Dim fs
Set fs = CreateObject
("Scripting.FileSystemObject")
If Not (fs.FileExists(TemplateDirectory &
rsTempDocs!TemplateFilename)) Or IsNull(rsTempDocs!
TemplateFilename) Then
If Not (Process_Errors(rsTemplates!
Template, "Missing/Invalid Template Word Document. Call
Programmer")) Then
Set fs = Nothing
MsgBox "Critical Error! Unable to
process! Aborting Mail Merge!",
vbCritical, "EvergreenWare"
GoTo Normal_Exit
End If
Set fs = Nothing
GoTo Get_Next_Record
End If
On Error GoTo MailMerge_Err
Dim objWord As Word.Application
Dim objDoc As Word.Document
Dim strSQl As String
Dim strConnection As String
' Set objWord = CreateObject
("Word.Application")
Set objWord = New Word.Application
Set objDoc = GetObject(TemplateDirectory &
rsTempDocs!TemplateFilename, "Word.Document")
' objWord.Application.Visible = True
strSQl = "Select * From " & txtSourceData & "
Where Selected = True and Template = " & Chr(34) &
rsTemplates!Template & Chr(34)
Set rsLetters = db.OpenRecordset(strSQl,
dbOpenSnapshot)
rsLetters.MoveLast
rsLetters.MoveFirst
prgBar.Value = IIf(prgBar.Value +
rsLetters.RecordCount > prgBar.Max, prgBar.Max,
prgBar.Value + rsLetters.RecordCount)
strConnection =
Application.CurrentProject.Path & "\MailMerge10.mdb"
objDoc.MailMerge.OpenDataSource
Name:=strConnection, SQLStatement:=strSQl
objDoc.MailMerge.Destination =
wdSendToNewDocument
objDoc.MailMerge.Execute Pause:=False
objDoc.Application.Options.PrintBackground =
False
objDoc.Application.ActiveDocument.PrintOut
objDoc.Close SaveChanges:=wdDoNotSaveChanges
objWord.Quit (wdDoNotSaveChanges)
Set objWord = Nothing
Get_Next_Record:
.MoveNext
Loop
End With
----------------------------------
this causes Opening this document will run the follow SQL
command: SELECT * FROM dtaRecoveryLetters Data from
your database will be placed in the document. Do you want
to continue?
I do not want this prompt to appear. The merge should be
seamless and not visible to the user. The document should
be merged, printed and the document closed.
any other suggestions? thanks for your assistance.
>-----Original Message-----
>Hi Courtney,
[quoted text clipped - 16 lines]
>
>.
Doug Robbins - Word MVP - DELETE UPPERCASE CHARACTERS FROM EMAIL ADDRESS - 18 Mar 2004 08:22 GMT
Use
Set objWord = New Word.Application
objWord.DisplayAlerts = wdAlertsNone
Set objDoc = objWord.Documents.Add(TemplateDirectory &
rsTempDocs!TemplateFilename, "Word.Document")

Signature
Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
>I am doing what you suggested. See my code that follows:
> With rsTemplates
[quoted text clipped - 120 lines]
>>
>>.
Courtney - 18 Mar 2004 14:54 GMT
Your suggested code line of ---
Set objDoc = objWord.Documents.Add(TemplateDirectory &
rsTempDocs!TemplateFilename, "Word.Document")
-- Causes Type Mismatch Error when executed.
thanks for the assistance.
>-----Original Message-----
>Use
[quoted text clipped - 130 lines]
>
>.
Courtney - 18 Mar 2004 15:23 GMT
The following code resolves all problems except the
follwoing dialog box still is displayed for each new
document:
"Opening this document will run the follow
SQL command: SELECT * FROM dtaRecoveryLetters
Data from your database will be placed in the document.
Do you want to continue?
Yes No"
How can this be answered with no user input?
Code =====================
Set objWord = New Word.Application
objWord.DisplayAlerts = wdAlertsNone
Set objDoc = objWord.Documents.Add
(Template:=TemplateDirectory & rsTempDocs!
TemplateFilename, NewTemplate:=False)
Set objDoc = GetObject(TemplateDirectory & rsTempDocs!
TemplateFilename, "Word.Document")
objWord.Application.Visible = False
>-----Original Message-----
>Your suggested code line of ---
[quoted text clipped - 158 lines]
>>
>.
Courtney - 18 Mar 2004 18:37 GMT
I have done further testing and resolution searching. I
found a KB article #825765 which discussed the problem I
was experiencing. I implemented the resolution via
RegEdit and now the Select Data Source Dialog is
displayed. This is such a simple tasks. Is there some
code example I can download? Again I have MS XP, Access
2003 and Word 2003. All latest service packs and patches
have been applied. Thanks.
>-----Original Message-----
>The following code resolves all problems except the
[quoted text clipped - 116 lines]
>>>>
>>>>
objDoc.Application.Options.PrintBackground
>=
>>>> False
[quoted text clipped - 70 lines]
>>
>.
Harold - 19 Apr 2004 20:26 GMT
The "Opening this document..." message is something that happens in Wor
2003 or Word 2002 SP3. I'm unable to determine if this is a bug, or i
this is a "feature" that Microsoft built into their new versions.
In order to turn this off, you have to add a VBA entry and edit th
registry. Here is the info from Microsoft...
http://support.microsoft.com/?scid=kb;en-us;825765
Here is a web page stating that this is a bug...
http://www.ucap.biz/Manuals/Error_Message_-_MS_Word_bug.htm
Hope this helps