Microsoft Access Forums

Go Back   Microsoft Access Forums > Access Forums > Programming

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 04-24-2006, 11:06 AM
Novice
 
Join Date: May 2005
Posts: 2
kfergus
Default Mail Merge problem

I am trying to merge data entered on a form with an existing word doc and am running into trouble. My code is:

Function MergeIt()
Dim HoldNotice2 As Word.Document
Set HoldNotice2 = GetObject("C:\Documents and Settings\kfergus\Desktop\HoldNotice2merge.doc", "Word.Document")

HoldNotice2.Application.Visible = True
HoldNotice2.MailMerge.OpenDataSource _
Name:="C:\Documents and Settings\kfergus\desktop\hold.mdb ", _
LinkToSource:=True, _
Connection:="TABLE Holdtbl", _
SQLStatement:="SELECT * FROM [Holdtbl]"

HoldNotice2.MailMerge.Destination = wdSendToNewDocument
HoldNotice2.MailMerge.Execute
HoldNotice2.Application.Options.PrintBackground = False
HoldNotice2.Application.ActiveDocument.PrintOut

HoldNotice2.Close

End Function

1/2 the time it works and the other 1/2 I get error messages about the db being unable to open or to be locked. When I debug it's always the same lines that I'm having trouble with, Set HoldNotice2... and HoldNotice2.MailMerge.OpenDataSource ... I verified the location and it's correct.

Help, please!
:cry:
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
E-mail Reports Mike Cooper Reports 2 08-03-2008 10:58 PM
Merge Code problems kfergus Access 1 06-01-2006 01:36 PM
Mail merge grgerhard Forms 0 04-25-2006 03:06 PM
Automatic E-mail Greg2582 Access 6 01-10-2006 11:36 AM


All times are GMT -8. The time now is 02:55 PM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
SEO by vBSEO 3.3.2 ©2009, Crawlability, Inc.