Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access VBA
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 6th, 2003, 10:35 AM
Registered User
 
Join Date: Jul 2003
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default (Semi) Automating Mail merge to Word

Hi all,

Not sure if this is the correct place to post this, but here goes anyway.

I'm performing a basic a mail merge from Access into Word, ceating the merge document on the fly in VB. This isn't a problem, as I can run right through and execute the merge successfully.

What I want be be able to do in addition, is carry out a merge to generate a letter template, and then leave word open to fillout the contents of the letter (ie. set up the datasource and some basic formatting, and then leave Word with the pre-merged document to add the content).

Now I thought this would be simple, and it is (in essence), but for some reason, when I specify a data source in VB, Word decides that I don't want any menus or toolbars anymore, and I can't find a way of getting them back. As a result, I have no way of formatting the letter or carrying out the merge!

Is there any way to restor toolbars (looked through the Word object browser, and can't find anything suitable).

To try and explain this better, here are a couple of bits of code

1. This opens word and creates me a new mailmerge doc, leaving the menus alone

Dim app As Object
Dim doc As Object

Set app = CreateObject("Word.Application")
Set doc = app.Documents.Add

With doc
  .MailMerge.MainDocumentType = wdFormLetters
  .MailMerge.EditMainDocument
  'Perform some basic text isnertion and formatting here...
End With

app.Visible = True
'User now has the document ready to edit and subsequently merge


2. Once I add code to open a datasource, all the menus disappear!

Dim app As Object
Dim doc As Object

Set app = CreateObject("Word.Application")
Set doc = app.Documents.Add

With doc
  .MailMerge.MainDocumentType = wdFormLetters
  .MailMerge.OpenDataSource Name:=CurrentDb.Name, sqlStatement:="Select * from [My Query]"
  .MailMerge.EditMainDocument
  'Perform some basic text isnertion and formatting here...
End With

app.Visible = True
'User now has the document ready to edit and subsequently merge
'But all the toolbars and menus have gone!!



Any help much appreciated

Cryolith





Similar Threads
Thread Thread Starter Forum Replies Last Post
Mail Merge with MS Word bezaman Classic ASP Basics 1 October 6th, 2005 04:13 PM
Access/Vba mail merge to word help alfonse Access VBA 0 July 28th, 2005 05:11 AM
Access to Word Mail Merge Automation kareltje Access VBA 6 June 9th, 2005 04:54 AM
Word E-Mail Merge using Access Tables Richard Lally Access 2 February 7th, 2005 04:48 AM
Wrap Up feature (like Word Mail Merge) jmurdock BOOK: Professional SQL Server Reporting Services ISBN: 0-7645-6878-7 0 June 28th, 2004 03:20 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.