straytoasters Posted March 4, 2008 Share Posted March 4, 2008 So I have this Excel file that I set a macro to save as %variable%.xls and I get results like:%username%.xlx = username.xls (where username is my real work username)%os%.xls = windows_NT.xls%date%.xls = %date%.xlsSo in the above examples, %username% and %os% change into the appropriate variables, but %date% stays %date%. Why is that? If I echo %date% in cmd it spits back the date, so why does some environmental variables work for Excel and not others. Is there a subset if Office environmental variables and %date% is not one of them?Straytoasters Link to comment Share on other sites More sharing options...
IcemanND Posted March 4, 2008 Share Posted March 4, 2008 %date% is not your normal environment variable. But there is a Date function that is part of the Excel function set.If Command Extensions are enabled, then there are several dynamicenvironment variables that can be expanded but which don't show up inthe list of variables displayed by SET. These variable values arecomputed dynamically each time the value of the variable is expanded.If the user explicitly defines a variable with one of these names, thenthat definition will override the dynamic one described below:%CD% - expands to the current directory string.%DATE% - expands to current date using same format as DATE command.%TIME% - expands to current time using same format as TIME command.%RANDOM% - expands to a random decimal number between 0 and 32767.%ERRORLEVEL% - expands to the current ERRORLEVEL value%CMDEXTVERSION% - expands to the current Command Processor Extensions version number.%CMDCMDLINE% - expands to the original command line that invoked the Command Processor. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now