Unfortunately, it's difficult to know how to reply to people who have made
full use of WP's facilities: it arguably always had a better way to do
merges. The basic problems with Word compared with WP (as I understand it
from a brief encounter with WP rather a long time ago!) are that
a. Word Macros are basically tied to Word templates and documents and lack
the independence of the sort of macros you could write in WP
b. Word MailMerge assumes a single tabular data source (i.e. same fields in
each row) whereas you could, in effect, structure a WP data source how you
wanted
c. Word's field language is poor (in fact I think its development was
basically abandoned in favour of effort on VBA, despite the fact that the
two things work in completely different ways.
I had a routine to reduce the full name of an insurance company to a
short name. (Like /Dominion of Canada/ to just /Dominion/.) And no, I
can't modify the merge field: I just get a .dbf file straight from IT.
I've been trying to figure out some way around Word's limitations. I
posted a message a while ago, and got a somewhat unhelpful answer to
forget what I could do in WP and move on to learn SQL or something.
If that message was from me, it would not have been posted without thought.
You simply won't find the facilities you had within WP. The easiest way to
replace /some/ of them is to adapt, and there are various ways to do that.
However, it isn't particularly easy to work around some of Word's
limitations, e.g. trying to use multiple data sources in a merge.
Using SQL to modify your data source is one way around some of the problems.
There are also plenty of fancy tricks you can do with fields, but in the end
there's either a fancy trick that can be used to achieve a particular
effect, or solve a particular problem, or there isn't, in which case you
obviously have to fnd a different approach.
For Field tips n tricks, useful sources are probably material by Cindy
Meister, Doug Robbins, Graham Mayor, Charles Kenyon, macropod and myself
(including the stuff posted on Greg Maxey's site). However, I don't know of
a really comprehensive list of such stuff, nor am I about to produce one in
the next 5 minutes
In my view the only way you are likely to be able to produce macros that
initiate merges that are even remotely similar to the stuff you did with WP
is to learn to use VBA (or VB.NET or whatever) to do the same thing. If you
want to get info. from users, you either use Word ASK/FILLIN fields over
which you will have little control, , or you use VBA-level facilities such
as VBA Userforms which unfortunately require you to dive headlong into VBA,
or simpler facilities such as VBA InputBox facilities.
WP has merge commands like ASSIGN(vTxt;FIELD(Txt)), to assign whatever
to the variable vTxt (in this case, a field), and string commands, so
then you can search for, say, the position of the first space with a
string position command like STRPOS(" ";vTxt) and combine it with a
substring command to subtract the bit you want and assign that to your
variable.
You just don't get this in the Word field system. Ways to achieve similar
things are:
a. manipulate the data source
b. use VBA and Word MailMerge Events to get at the data in your data source
before it gets stuffed into the mail merge main document
c. use a DATABASE field to extract info. from a mailmerge field.
Unfortunately, this can only be sed if you can guarantee that your data does
not have characters such as single-quotes in it, and MS has done something
in recent version sof Word that makes this much more unreliable.
Is there no way to invoke VBA? You know, somehow assign that field with
the name to a variable, then invoke VBA to manipulate it, then insert
the modified variable into the document? Again, I've done that with
fields where I get want the user to be able to modify the info if need
be, but not necessarily. [The routine is: 1. assign field to variable..
2. invoke macro with prompt where variable pre-fills the prompt. 3.
user can modify or not the variable. 4. macro stops, variable is
inserted into text in WP's merge language.]
Yes, use Word events. Have a look at Cindy Meister's website or look for
articles in this group (e.g. via groups.google.com). But you can't insert
the modified field using a MERGEFIELD field: you either have to stuff the
modified text into the document or update a Document variable or Document
property which is then inserted during the merge using a { DOCVAROABLE }
field or { DOCPROPERTY } field.
My best shot for now...
Peter Jamieson
fscodave said:
That's /exactly/ the type of text manipulation I've been able to do in
WP in its merge language and have failed to figure out how to do in
Word. At least now I know not to waste my time.
I had a routine to reduce the full name of an insurance company to a
short name. (Like /Dominion of Canada/ to just /Dominion/.) And no, I
can't modify the merge field: I just get a .dbf file straight from IT.
I've been trying to figure out some way around Word's limitations. I
posted a message a while ago, and got a somewhat unhelpful answer to
forget what I could do in WP and move on to learn SQL or something.
WP has merge commands like ASSIGN(vTxt;FIELD(Txt)), to assign whatever
to the variable vTxt (in this case, a field), and string commands, so
then you can search for, say, the position of the first space with a
string position command like STRPOS(" ";vTxt) and combine it with a
substring command to subtract the bit you want and assign that to your
variable.
Sigh.
Is there no way to invoke VBA? You know, somehow assign that field with
the name to a variable, then invoke VBA to manipulate it, then insert
the modified variable into the document? Again, I've done that with
fields where I get want the user to be able to modify the info if need
be, but not necessarily. [The routine is: 1. assign field to variable..
2. invoke macro with prompt where variable pre-fills the prompt. 3.
user can modify or not the variable. 4. macro stops, variable is
inserted into text in WP's merge language.]
But so far I haven't found the equivalent of WP's VARIABLE(vTxt)
command to insert the modified-or-not variable into the text...
David Evans
Peter said:
I would go Graham's route, but if you cannot do that, you can probably
have
26 IF fields that do e,.g.
{ IF "{ MERGEFIELD Lead_PersonFirstname }" = "A*" "A" ""
}{ IF "{ MERGEFIELD Lead_PersonFirstname }" = "B*" "B" ""
}
and so on...
Peter Jamieson