Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Mailmerge and Fax / July 2005

Tip: Looking for answers? Try searching our database.

Another access-word mailmerge question

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Mike - 18 Jul 2005 16:01 GMT
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
Doug Robbins - 18 Jul 2005 17:15 GMT
Try without that construction.  The result of the merge will almost (if not
completely) certainly end up as the active document.

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Hi, I would like to perform a mailmerge by clicking a button on an
> access form.
[quoted text clipped - 39 lines]
>
> Thanks, Mike
Mike - 19 Jul 2005 08:59 GMT
Thanks Doug, think that does it!

However I have another question, to close down I have (in addition to
the above) the following:

objDoc.Close wdDoNotSaveChanges

Set objDoc = Nothing
Set Word.Global = Nothing

objWord.Quit wdDoNotSaveChanges
Set objWord = Nothing

but Word is now being closed so fast that it can't handle the
printout-execution.

How can I delay this, just using a simple loop like:

for x = 1 to 100000000000000000000000000000
    x=x+1
next x

or something or is there a better solution?

Thanks, Mike
Doug Robbins - 19 Jul 2005 11:56 GMT
Set the Background Print attribute to false

objWord.ActiveDocument.PrintOut Background: = False

That will prevent the next line of code from executing until the printing is
complete (spooled)

Signature

Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP

> Thanks Doug, think that does it!
>
[quoted text clipped - 21 lines]
>
> Thanks, Mike
Mike - 19 Jul 2005 12:41 GMT
Ok, another great solution, thanks for your help!

Mike

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.