OpenDataSource issues

J

Jim Rendant

I am having problems with office 2003 and mailmerge from access using VBA.

I set the merge document name (mergedoc) to the file to use for the main
document. Based on the type of document I also create a SLQstr to retrieve
the proper data for that particular main document.

When I open the document I get a "Confirm DataSource" dialog box which I am
hoping NOT to see since I belive I have provided the proper information to
OpenDataSource.

After confirmation, the document does gets merged, printed and the merge
document closed BUT the word application DOES NOT close which is al required
since i want to fully automate this process

Thanks In Advance .....

Here is the code:

Set objWord = GetObject(mergdoc, "Word.Document")
' Make Word visible.
objWord.Application.Visible = True
objWord.MailMerge.OpenDataSource _
Name:="q:\photography.mdb ", _
LinkToSource:=True, _
ReadOnly:=True, _
Connection:="TABLE Picture_Data", _
SQLStatement:=SQLSTR

' Execute the mail merge.
objWord.MailMerge.Execute
objWord.Application.ActivePrinter = "\\manager\HP LaserJet 5/5M PostScript"
'objWord.Application.PrintOut

objWord.Application.Documents(1).Close (wdDoNotSaveChanges)
objWord.Close (wdDoNotSaveChanges)

Set objWord = Nothing
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?SmltIFJlbmRhbnQ=?=,
BUT the word application DOES NOT close
objWord.Application.EXIT

When I open the document I get a "Confirm DataSource" dialog box which I am
hoping NOT to see since I belive I have provided the proper information to
OpenDataSource.
Try recording linking manually to the data source in a macro. Then compare the
macro recorder result to your code. Likely, there's some little thing that's
missing.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 
J

Jim Rendant

Creat a Macro in Word or Access?
If in Access what/where should I begin.
In word I am to assume you mean create a merged document and see what the
Macro looks like? I have done this and have take the macro verbatim into
Access only to see it fail.

Help please????
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?SmltIFJlbmRhbnQ=?=,
Creat a Macro in Word or Access?
If in Access what/where should I begin.
In word I am to assume you mean create a merged document and see what the
Macro looks like? I have done this and have take the macro verbatim into
Access only to see it fail.
I mean record a macro in WORD while linking to the Access database (only
that part of the process). copy paste the result into your reply, please?

Comment: Word 2002 and 2003 use OLE DB to connect, by default. OLE DB
doesn't work optimally with Access or Excel (both use the JET engine). My
preference, for automating these two apps, is an ODBC connection.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top