Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 06-20-2013, 05:15 AM
Charles Kenyon Charles Kenyon is offline Document Creation Windows Vista Document Creation Office 2010 32bit
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,602
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Assuming that all of your information is in one Excel file.

I do this regularly using a mailmerge.

I have various templates with the mailmerge fields in them. There is an AutoNew macro in these templates that attaches the Excel file as a data source and calls up the built-in dialog to pick a record.

Code:
Sub AttachClients()
'   Written by Charles Kenyon
'   19 April 2005 revised 15 December 2006
'
'   Requires WorkGroupPath function
'
'   Makes activedocument a mailmerge (letter) document and
'   attaches Clients_Merge.xls from Parts folder of Workgroup Templates folder.
'
'   Then displays search dialog and goes to client, makes sure merge info is
'   displayed instead of merge codes.
'
    On Error Resume Next
    MergeFieldUnlockAllStory 'if merge fields locked, unlock
'
'   Name of file
    Dim strFileName As String
    Dim strProvider As String
    strFileName = WorkGroupPath & "Parts\Merge Data\Clients_Merge.xls"
'
'   Attach Merge list
    ActiveDocument.MailMerge.OpenDataSource strFileName, , , False, _
        True, False, "", "", False, "", "", "Provider=Microsoft.Jet.OLEDB.4.0;Password="""";User ID=Admin;Data Source=strFileName;Mode=Read;Extended Properties=""HDR=YES;IMEX=1;"";Jet OLEDB:" _
        , "SELECT * FROM `Clients$`", "", , wdMergeSubTypeAccess
'
'   Show merge data
    ActiveDocument.MailMerge.ViewMailMergeFieldCodes = False
'
'   Find client
    Application.Dialogs(wdDialogMailMergeFindRecipient).Show
End Sub
The WorkgroupPath function gives a string for the Workgroup folder path.
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Calendar Creation sjvjoe Publisher 1 07-14-2016 06:32 PM
Help with Complex Table Creation saquib Word 0 02-12-2013 06:28 AM
Creation and Merge trouble Etera Mail Merge 0 07-27-2011 02:57 PM
Document Creation Label Creation speloquin Word 1 05-27-2011 03:08 PM
Report creation. Igtech Excel 1 04-02-2010 03:33 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:56 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft