Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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. . |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
merge two excel files like in word mail merge | Excel Discussion (Misc queries) | |||
Problem opening up current Excel wksht to mail merge in Word | Excel Discussion (Misc queries) | |||
Help please with Excel 03 for mail merge with Word 03! | Excel Discussion (Misc queries) | |||
Excel 2 Word 2 OE 2 Mail Merge | New Users to Excel | |||
Excel Word Mail Merge | Excel Worksheet Functions |