Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 4
Default Excel/Word Mail Merge Problem

You need to select the distinct customers from the csv
file before doing the main merge. This code should get you
most of the way the
The [ ] and comment lines are where you need to make
changes- replace the [] too. I assumed that your CSV file
has column names.

Sub xx()

Cnn="Provider=MSDASQL;Driver={Microsoft Text Driver
(*.txt; *.csv)};DBQ=c:\[YOUR LOCATION];"
Sql="Select distinct(customer)[ add other columns
separated by ,] from [YOUR FILE NAME]"
Set ADORS=CreateObject("ADODB.Recordset")
ADORS.Open Sql,Cnn
' Open a text file here with handle FileHwnd

While NOT ADORS.EOF
print FileHwnd,ADORS.GetString
wend

'Close file here (its tab delimited)
'Read in Excel & save as csv under a new name as xls.

Mailmerger with existing Word setup & new excel file



-----Original Message-----
Can anybody help me with a mail merge problem please?



What we do now

When we have a product recall at work, we can run a

report from our Sales
Order system, which outputs to a comma-separated text

file, a list of
customers together with the Batch Number, Order Number,

Description, Date
etc. of their order.



We import the text file into Microsoft Excel and use it

as a mail merge
list. The relevant fields are inserted into a Microsoft

Word mail-merge
document, printed and sent to the customer.



The Problem

Some customers may have several orders of the same

recalled product, often
more than ten. If a customer has more than one order for

the product, then
they get a letter for each order e.g. 10 orders = 10

letters telling them
same thing. The only thing that changes is the order

number and date. The
customer details, product description and batch number

stay the same.



Required Solution

Is there any way to have the mail merge print one letter

per customer and
simply list the Order Numbers and Purchase Dates within

the same letter?



Office Version

Office XP



I would appreciate any help on this, even to point me in

the right
direction. My guess is that you somehow read the

contents of the
spreadsheet cells into resizable arrays and somehow print

the contents into
the mail merge Word document, adding a new line to the

word document for
each Order Number found for a particular customer, and

then move on to the
next letter/customer.



Perhaps this can all be done within Excel?



The trouble is my VBA isn't that good.



Please send any help to



Thanks in advance for any help you can give me.



P.S. I have sent this email to a few word/excel groups

since it involves
both progames - I hope this is all right.




.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
merge two excel files like in word mail merge azmerritt Excel Discussion (Misc queries) 1 December 11th 16 09:23 PM
Problem opening up current Excel wksht to mail merge in Word Preciouskisz Excel Discussion (Misc queries) 0 January 8th 10 08:53 PM
Help please with Excel 03 for mail merge with Word 03! Mldapril17 Excel Discussion (Misc queries) 0 September 17th 08 05:22 AM
Excel 2 Word 2 OE 2 Mail Merge New Orleans Novice New Users to Excel 2 March 31st 08 01:26 PM
Excel Word Mail Merge Yendorian Excel Worksheet Functions 8 February 22nd 08 10:51 PM


All times are GMT +1. The time now is 02:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"