View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
ChristopherL ChristopherL is offline
external usenet poster
 
Posts: 18
Default How do I set an environment variable to a string

On Aug 13, 12:12*am, ChristopherL wrote:
On Aug 12, 6:10*pm, Bob Bridges
wrote:

Says here there's an Environ function you can use, eg vx = Environ("PATH").


--- "ChristopherL" wrote:
How do I set an environment variable to a string- Hide quoted text -


- Show quoted text -


Sorry, I need to clarify my question. I did not want to determine the
contents of an environment variable! What I want to do is be able to
go out to the "command prompt" and set an arbitrary environment
variable.

I tried the following, but VBA tells me the path to the command was
not found:

dim ev_result as string

en_result = shell ("""set chris=1 2 3""")

The 3 sets of double quotes is to try to simulate doing the following
in a command prompt window: set chris="1 2 3".

Again, I want to set an environment variable within VBA.


Sorry again, I think I have a partial solution, if not a complete
solution! I'll try it tomorrow. Please critique me

dim ev_result as string

ev_result = shell ("\cmd ""set chris=1 2 3""")

en_result = Environ ("chris")
'en_result should be "1 2 3"

Thank you everyone in VBA land,
Chris