User Merge Field

J

Jo Davis

Hi

I am trying to create a merge document, i want to insert a merge field of
the user that is logged onto the computer and using the merge document at
that time, can this be done???

Jo
 
P

Peter Jamieson

One possibility is to use a { USERNAME } field, which inserts the name of
the user as specified in the User info. for /Word/.

If you really need the "user name" that is set up in the user's environment
(i.e. the one that is displayed if you use a SET command in aDOS/CMD box),
there is no built-in /Word/ field that can do it, and whether or not you can
get the value as a /merge/ field depends on what your data source is - e.g.,
you /might/ be able to get it from an Access database by using an
environ('username') function call in an Access query, but even that depends
on whether or not Access is operating in "sandbox mode", which is to do with
security.

You could also probably use a bit of Word VBA (and the Environ("username")
function call) to insert the required value, oryou might be able to use a
Word Auto macro to set up the value of a Word document variable or property
that you could insert using a { DOCVARIABLE } or { DOCPROPERTY } field.

So it's not straightforward, but maybe that will give you some options with
which you can experiment.

Peter Jamieson
 
G

Gert Raes

In addition to this post, the next question :

I use the wordfield "username" in a document.
When I use that field in an If-Then-Else Statement, the result is always the
not true - value.

Anyone an idea ?
 
P

Peter Jamieson

If you have the username field set to say "Gert Raes" and you use

{ IF { USERNAME } = "Gert Raes" "match" "no match" }

you should see "match.

If you have the username field set to "Gert" and you have

{ IF { USERNAME } = "Gert "match" "no match" }

then you should see "match", unless you also have a bookmark called "Gert"
that is set to something other than "Gert". In that case you might see "no
match". In that case, to ensure (in almost every case) that you see "match,
put quotes around the USERNAME field

{ IF "{ USERNAME }" = "Gert "match" "no match" }

The user name needs to match whatever you are comparing it with /exactly/,
otherwise you will get "no match". e.g. if capitalisation can vary, use

{ IF "{ USERNAME \*Upper } = "GERT "match" "no match" }

If none of that explains what you see, please spell out what your fields
actually contain.

Peter Jamieson
 
D

Doug Robbins - Word MVP

Peter was the omission of the closing quote after "Gert or "GERT an
oversight or a bit of shorthand?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Peter Jamieson

Doug...

It was a mistake...

Peter
Doug Robbins - Word MVP said:
Peter was the omission of the closing quote after "Gert or "GERT an
oversight or a bit of shorthand?

--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
P

Peter Jamieson

It was a mistake...

i.e. a couple of mistakes by me - the two relevant examples should be

{ IF { USERNAME } = "Gert" "match" "no match" }

and

{ IF "{ USERNAME \*Upper }" = "GERT" "match" "no match" }

Peter Jamieson
 

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