Can't sort data from mailmerge-file before merging

T

twoface

Hello,

Searching all through the internet, I am out of ideas to how to sort
the data in my mailmerge-file.

The file is obtained from another program, which outputs a tabulator
seperated file for merging. The problem is that it is sorted by the
wrong column.

The SQL would be something like "SELECT * FROM <filename.doc> (?)
ORDER BY deltfnavn ASC", but SQL is not allowed, when the datasource
is tabulator seperated.

Regards,
Tue
 
T

twoface

Problem solved!

Although it is a ressource-demanding, I made word open excel and sort
it through there.

Here's the code, if anyone is interested:

Set xlApp = CreateObject("Excel.Application")
xlApp.Visible = True
Set xlWbk = xlApp.Workbooks.Open(MergeData)
Set xlSht = xlWbk.Worksheets(1)
xlSht.UsedRange.Sort Key1:=xlSht.Range("AD1"),
Key2:=xlSht.Range("AE1"), header:=xlGuess
xlWbk.Close True
xlApp.Quit

Regards,
Tue
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top