querying environment variables from vba 
Author Message
 querying environment variables from vba

Hello All,
Can someone please tell me if it's possible to query an
environment variable for use in a macro?  If I have a cmd
prompt open and type set, I get  list of all the env.
variables.  I see the environment variable
called "UserName" is set to BBJohnson and it would be such
a huge improvement to my macro if I could get that
information from that variable.


Sat, 17 Dec 2005 03:27:58 GMT  
 querying environment variables from vba
Hi DCurren,

See the article "How to get the username of the current user" at:

http://www.mvps.org/word/FAQs/MacrosVBA/GetCurUserName.htm

Please respond to the newsgroups for the benefit of others who may be
interested.

Hope this helps
Doug Robbins - Word MVP

Quote:
> Hello All,
> Can someone please tell me if it's possible to query an
> environment variable for use in a macro?  If I have a cmd
> prompt open and type set, I get  list of all the env.
> variables.  I see the environment variable
> called "UserName" is set to BBJohnson and it would be such
> a huge improvement to my macro if I could get that
> information from that variable.



Sat, 17 Dec 2005 08:31:59 GMT  
 querying environment variables from vba
Thanks a lot - that worked with just a little modification.
I would never have figured that out on my own.  I even
looked around on the mvps site but did not use the proper
search terms.

Although this works fine for the present macro, it would
probably come in handy later - is there a way to query the
environment variables?

Quote:
>-----Original Message-----
>Hi DCurren,

>See the article "How to get the username of the current
user" at:

>http://www.mvps.org/word/FAQs/MacrosVBA/GetCurUserName.htm

>Please respond to the newsgroups for the benefit of
others who may be
>interested.

>Hope this helps
>Doug Robbins - Word MVP


>> Hello All,
>> Can someone please tell me if it's possible to query an
>> environment variable for use in a macro?  If I have a
cmd
>> prompt open and type set, I get  list of all the env.
>> variables.  I see the environment variable
>> called "UserName" is set to BBJohnson and it would be
such
>> a huge improvement to my macro if I could get that
>> information from that variable.

>.



Sun, 18 Dec 2005 00:27:44 GMT  
 querying environment variables from vba
Hi DCurren,

Yep, this will work on a Microsoft network, but isn't guaranteed on other
network types:

Sub ShowUserName()
    Dim uname As String
    uname = Environ("USERNAME")
    MsgBox uname
End Sub

Check the Help topic on the Environ function. It doesn't work at all on a
Macintosh.

--
Regards,
Jay Freedman
Microsoft Word MVP          FAQ: http://www.mvps.org/word

Quote:

> Thanks a lot - that worked with just a little modification.
> I would never have figured that out on my own.  I even
> looked around on the mvps site but did not use the proper
> search terms.

> Although this works fine for the present macro, it would
> probably come in handy later - is there a way to query the
> environment variables?

>> -----Original Message-----
>> Hi DCurren,

>> See the article "How to get the username of the current user" at:

>> http://www.mvps.org/word/FAQs/MacrosVBA/GetCurUserName.htm

>> Please respond to the newsgroups for the benefit of
> others who may be
>> interested.

>> Hope this helps
>> Doug Robbins - Word MVP


>>> Hello All,
>>> Can someone please tell me if it's possible to query an
>>> environment variable for use in a macro?  If I have a cmd
>>> prompt open and type set, I get  list of all the env.
>>> variables.  I see the environment variable
>>> called "UserName" is set to BBJohnson and it would be such
>>> a huge improvement to my macro if I could get that
>>> information from that variable.

>> .



Sun, 18 Dec 2005 04:11:52 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Get a value from a SELECT query into a VBA variable:

2. VBA, variables & query

3. How to use variables in a sql query using VBA

4. Query Object vs VBA Query

5. Environment variable...

6. Write Environment Variables

7. Environment Variables

8. Environment Variables

9. WORD Environment Variables

10. Using Environment Variable in Template path

11. environment variables

12. Extracting environment variables

 

 
Powered by phpBB® Forum Software