Using the environ function in a world field

D

DanMurphy

Hello All

I am using Word 2007, and trying to make a word template with a user
signature automatically present depending on the user that opens th
document.

I am having little success at the moment however, I am brutishl
inexperienced with Word VBA. :(

My first attempt was a straightforward inclusion in the word fields

{INCLUDEPICTURE C:\\Signatures\\Environ("Username").bmp}

which returned a broken picture symbol.

My second attempt has been to have a wrapper function around it.

Public Function EMPNAME()

EMPNAME = Environ("Username")

End Function

But including
{INCLUDEPICTURE C:\\Signatures\\{=EMPNAME()}.bmp}

Just returns syntax error. :(


Could anyone point me in the right direction? It would be greatl
appreciated
 
S

Stefan Blom

The Environ function can be used, from within Visual Basic for Applications, to
return paths represented by environment variables. It can't be embedded in a
field code.

--
Stefan Blom
Microsoft Word MVP




"DanMurphy" wrote in message

Hello All

I am using Word 2007, and trying to make a word template with a users
signature automatically present depending on the user that opens the
document.

I am having little success at the moment however, I am brutishly
inexperienced with Word VBA. :(

My first attempt was a straightforward inclusion in the word fields

{INCLUDEPICTURE C:\\Signatures\\Environ("Username").bmp}

which returned a broken picture symbol.

My second attempt has been to have a wrapper function around it.

Public Function EMPNAME()

EMPNAME = Environ("Username")

End Function

But including
{INCLUDEPICTURE C:\\Signatures\\{=EMPNAME()}.bmp}

Just returns syntax error. :(


Could anyone point me in the right direction? It would be greatly
appreciated.
 

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