ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   %SYSTEMROOT%/Temp variable (https://www.excelbanter.com/excel-programming/319000-%25systemroot%25-temp-variable.html)

R. Choate

%SYSTEMROOT%/Temp variable
 
Is anybody familiar with using this syntax as a variable for a path? I have a project with a hard-coded path to C:/WINNT/TEMP

Unfortunately this is causing problems with the new laptops with Office 2003 loaded OEM. They don't have that directory and I've
been asked to try this variable shown in my subject line: %SYSTEMROOT%/Temp

I could use some advice here.
--
RMC,CPA




Tom Ogilvy

%SYSTEMROOT%/Temp variable
 
That is the format for working with BAT files. For excel/vba, you can use
the environ function

Sub tester1()
For i = 1 To 20
Debug.Print Environ(i)
Next
End Sub

produces:
TMP=C:\WINDOWS\TEMP
TEMP=C:\WINDOWS\TEMP
PROMPT=$p$g
winbootdir=C:\WINDOWS
PATH=C:\Program Files\Microsoft Office\Office;C:\WINDOWS;C:\WINDOWS\COMMAND
COMSPEC=C:\WINDOWS\COMMAND.COM
windir=C:\WINDOWS
BLASTER=A220 I5 D1

so if you wanted a specific variable you can do

vVar = Environ("Temp")
or
vVar=Environ("comspec")
as examples:

? environ("Temp")
C:\WINDOWS\TEMP
? environ("Comspec")
C:\WINDOWS\COMMAND.COM
? environ("Windir")
C:\WINDOWS


--
Regards,
Tom Ogilvy


"R. Choate" wrote in message
...
Is anybody familiar with using this syntax as a variable for a path? I

have a project with a hard-coded path to C:/WINNT/TEMP

Unfortunately this is causing problems with the new laptops with Office

2003 loaded OEM. They don't have that directory and I've
been asked to try this variable shown in my subject line:

%SYSTEMROOT%/Temp

I could use some advice here.
--
RMC,CPA






R. Choate

%SYSTEMROOT%/Temp variable
 
Thanks once again. You are the man, that's for sure.
--
RMC,CPA


"Tom Ogilvy" wrote in message ...
That is the format for working with BAT files. For excel/vba, you can use
the environ function

Sub tester1()
For i = 1 To 20
Debug.Print Environ(i)
Next
End Sub

produces:
TMP=C:\WINDOWS\TEMP
TEMP=C:\WINDOWS\TEMP
PROMPT=$p$g
winbootdir=C:\WINDOWS
PATH=C:\Program Files\Microsoft Office\Office;C:\WINDOWS;C:\WINDOWS\COMMAND
COMSPEC=C:\WINDOWS\COMMAND.COM
windir=C:\WINDOWS
BLASTER=A220 I5 D1

so if you wanted a specific variable you can do

vVar = Environ("Temp")
or
vVar=Environ("comspec")
as examples:

? environ("Temp")
C:\WINDOWS\TEMP
? environ("Comspec")
C:\WINDOWS\COMMAND.COM
? environ("Windir")
C:\WINDOWS


--
Regards,
Tom Ogilvy


"R. Choate" wrote in message
...
Is anybody familiar with using this syntax as a variable for a path? I

have a project with a hard-coded path to C:/WINNT/TEMP

Unfortunately this is causing problems with the new laptops with Office

2003 loaded OEM. They don't have that directory and I've
been asked to try this variable shown in my subject line:

%SYSTEMROOT%/Temp

I could use some advice here.
--
RMC,CPA








All times are GMT +1. The time now is 12:57 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com