Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Access 2003 VBA Programmer's Reference
This is the forum to discuss the Wrox book Access 2003 VBA Programmer's Reference by Patricia Cardoza, Teresa Hennig, Graham Seach, Armen Stein; ISBN: 9780764559037
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Access 2003 VBA Programmer's Reference section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 9th, 2004, 07:59 AM
Authorized User
 
Join Date: Jun 2004
Location: Boness, Falkirk, United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Access automation

Hi - I was wondering if someone could help me? I'll start at the begining: I need a user to open a word document (from Access) which has some static text(mail merge) and I need to append data from a form to it. This isn't a problem I've used the basic code shown in the automation chapter (sorry at work and can't remember the chapter nr) with some slight modifications - API call to CMDLG32.dll assigning the file name to a string and passing the string to the getobject function as a parameter. Now the problem starts I get 2 word documents opened, the merge template document and another "Formdocument" both with the same info? Is it possible only to open the new document with all the staic and dynamically assigned text?

Code snippit below. (Be kind to me I'm new to this game ;o))

Private Sub CmdGetCmnDlg_Click()
On Error GoTo Err_CmdGetCmnDlg_Click

Dim strPath As String
Dim WordDoc As Word.Document

strPath = GetFile

If (strPath = "") Then
  Exit Sub
Else

Set WordDoc = GetObject(strPath)
WordDoc.Application.Visible = True

WordDoc.MailMerge.OpenDataSource *****...................etc
WordDoc.MailMerge.Execute

Cheers Wullie

William
__________________
William
Reply With Quote
  #2 (permalink)  
Old July 27th, 2004, 10:09 AM
Authorized User
 
Join Date: Jun 2004
Location: Cumberland, MD, USA.
Posts: 43
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I just received a copy of this book. Although I don't use Word very much, I was intrigued by your question. I started playing around just to see what this MailMerge "stuff" was all about. I don't have all the answers ... in fact I probably have more questions now.

I think that this procedure opens the Word template and creates a new document with fields from a record from the database that you reference. If you put the following statement at the bottom of your procedure:

objWord.Close

I observed that the template disappears and only the new document remains. If you set your template up to Merge to the printer (rather create a new document), copies of your template will print ... one copy for each record.

The only problem I had was that the Access database (used as the DataSource) remained open after the procedure completed (and remained open even after I exited from Access. One thing is sure ... there more to this stuff than meets the eye.

Terry Waltz
Reply With Quote
  #3 (permalink)  
Old July 29th, 2004, 11:36 AM
Wrox Author
 
Join Date: May 2004
Location: , , .
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
Default

William,

Terry is right. If you add objWord.Close to the end of the prodceure, you should see the results you're looking for. I do a lot with Word automation so post back with any other questions.


Patricia Cardoza
Outlook MVP

Lead Author, Access 2003 VBA Programmer's Reference
Reply With Quote
  #4 (permalink)  
Old July 30th, 2004, 07:59 AM
Authorized User
 
Join Date: Jun 2004
Location: Boness, Falkirk, United Kingdom.
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi Terry and Patricia - Thanks for the replies. I actually posted the same question to the access/vba forum and someone recommended using a reference to a word application instead of a word document and it works fine. I'm now in the process of trying to save the opened word document as an ole object into a table, which is then shown in a subform of the original form. Not to easy - I'm sure i'll be back to ask for help. Speak to you all later.

William
Reply With Quote
Reply


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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Outlook Automation in Access arielalevy Access VBA 1 June 27th, 2006 07:00 PM
Access to Word Mail Merge Automation kareltje Access VBA 6 June 9th, 2005 04:54 AM
Automation with Access and Excel venomm Access 2 March 20th, 2005 10:34 AM
access to excel automation...seem to still have a mytfein Access VBA 0 September 9th, 2004 09:35 AM
OLE Automation Access - Word william.murray Access 2 July 13th, 2004 07:23 AM



All times are GMT -4. The time now is 02:38 AM.


Powered by vBulletin® Version 3.7.0
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.