Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Mike
 
Posts: n/a
Default Another access-word mailmerge question

Hi, I would like to perform a mailmerge by clicking a button on an
access form.

I have the following code:

Dim objWord As Word.Application
Dim objDoc As Word.Document

Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Open("E:\Rechtsbijstand Certificaten\RB
Certificaat Certificaat.doc")

With objWord
.Visible = True
.WindowState = wdWindowStateMaximize
End With

objDoc.MailMerge.OpenDataSource _
Name:=CurrentDb.Name, _
LinkToSource:=True, _
Connection:="TABLE TblSamenvoeg", _
SQLStatement:="Select * from [TblSamenvoeg] WHERE [PolisId]="&
Form_FormPolInv.PolisId.Value
objDoc.MailMerge.Execute

'because I get 2 documents, the original and the merged one I use:
If InStr(ActiveDocument.Name, "RB Certificaat Certificaat") = 0 Then
Set DocResult = Documents(1)
Else
Set DocResult = ActiveDocument
End If

objWord.ActiveDocument.PrintOut

But at the InStr-line I get an error (4248) saying that the document is
not there, but they are there!

So the merging goes OK, but the printing isn't done.

What is going wrong?

Thanks, Mike

 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Please give us REVEAL CODES like WORD PERFECT not reveal codes in. Rachel King Microsoft Word Help 38 August 21st 09 09:54 PM
Locking Two Words Together to Make a Proper Compound Noun in Word WorkingWoman Microsoft Word Help 2 April 7th 05 02:33 PM
creating forms Fluffypink Microsoft Word Help 4 March 9th 05 04:17 PM
Mailmerge from VB to WORD 2002 with Access [email protected] Mailmerge 5 February 7th 05 05:16 PM
WP Delay Code - Word Equiv Mike G - Milw, WI Microsoft Word Help 6 January 10th 05 04:12 PM


All times are GMT +1. The time now is 06:33 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"