Word Macros

M

Martin Harper

Further to my previous post I have now been able to deal
with the issue of the dialog box for the mergedata source
file type by called my file .txt - quite simple really.

However I still have a problem with mereging the data and
it must surely be simple and possible for me to have a
comand in my macro or at least a setting in Word (2002)
which allows me to tell the mailmerge command that I am
using a specific delimiter for my records and a specific
delimiter for fields. It does not matter what these are
as I can make them anything I want but I need desperately
to know how to tell the macro what these are.

Thanks in advance

Martin Harper
 
D

Doug Robbins - Word MVP

Hi Martin,

If you can make them anything you want, I am pretty sure that if you use a
comma to delimit the fields and a carriage return to delimit the records,
that is what Word will be expecting. If your data includes commas in a
field then use enclose each field in double quotes.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

Hope this helps
Doug Robbins - Word MVP
 
M

Martin HArper

Doug,

Thanks for trying but this did not help - I am still
asked for the delimiters.

It does not look like Word can handle this which in my
opinion is ridiculous. This means I will have to stay
with Wordperfect which is going to cost a lot to have
alongside office.

Is there any Microsoft contact that might be able to
answer this question?

Martin
 
M

Mike NG

However I still have a problem with mereging the data and
it must surely be simple and possible for me to have a
comand in my macro or at least a setting in Word (2002)
which allows me to tell the mailmerge command that I am
using a specific delimiter for my records and a specific
delimiter for fields. It does not matter what these are
as I can make them anything I want but I need desperately
to know how to tell the macro what these are.
Martin

I have dim and distant problems similar to what you're describing - well
having trouble getting the mail merge data file to be interpreted
correctly


I just write to a text file with a .doc extension, using vbTab as the
field separator. Make sure you also write the field header line in the
same way

In my mail merge main document, I don't need to tell it what the
separator is - it just works
 
M

Martin Harper

Mike

Thanks for the advice. Two poblems... 1. My mail merge
file has 450 fields and will not fit onto one line so it
is difficult to set up with tab delimiters. 2. How do I
get a vbTab delimiter into the text document?

Thanks

Martin
 
M

Mike NG

Thanks for the advice. Two poblems... 1. My mail merge
file has 450 fields and will not fit onto one line so it
is difficult to set up with tab delimiters. 2. How do I
get a vbTab delimiter into the text document?

I'm not sure where you are generating your mail merge data, but this is
what I do. Even though when you view the document each line will wrap
around, that doesn't matter because the carriage return marks the end of
the record

If it's impractical to put all of your 450 fields in one statement, I
can't remember if Print has an option to not print the carriage return.
If it hasn't, you'll have to build a string up within your code

Dim i As Integer
Dim iHandle As Integer

i = ActiveCell.Row

iHandle = FreeFile
Open ThisWorkbook.Path & "\EnvelopeData.doc" For Output As #iHandle

Print #iHandle, "Nme"; vbTab; "Add1"; vbTab; _
"Add2"; vbTab; "Add3"; vbTab; "Add4"; vbTab; _
"Add5"; vbTab; "PstCde"

Print #iHandle, Cells(i, 1); vbTab; Cells(i, 2); vbTab; _
Cells(i, 3); vbTab; Cells(i, 4); vbTab; Cells(i, 5); _
vbTab; Cells(i, 6); vbTab; Cells(i, 7)


Close #iHandle
 
M

Martin Harper

Mike, I I was hopeing this would overcome the problem.
What do you think?

Martin
 
M

Martin Harper

Hi Doug,

You will be pleased to know that SENDKEYS solved my
problem. I had a bit of trouble at first because my first
delimiter is {ENTER} but it was taking it as a keystroke
so I ended up with a longer string of keystrokes. Once
you get the idea that you have to key every keystroke
(rather than sending input to a dialog box) it is quite
straightforward.

So thanks for all your help. Thanks to Mike too.

Martin Harper
 
D

Doug Robbins - Word MVP

Hi Martin,

I thought that you records were delimited with and end of paragraph mark
with is the default, so the SendKeys string should have only needed # and
one tilde (=Enter) to accept that and a second one to what would then be
displayed in the dialog box (if it were displayed) which would be the # for
the field delimiter and the ¶ for the recond delimiter.

Anyway, glad that we got it sorted out eventually.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a consulting basis.

Hope this helps
Doug Robbins - Word MVP
 

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