Jump to content

Excel 2003 environmental variables


straytoasters

Recommended Posts

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%.xls

So 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


%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 dynamic

environment variables that can be expanded but which don't show up in

the list of variables displayed by SET. These variable values are

computed dynamically each time the value of the variable is expanded.

If the user explicitly defines a variable with one of these names, then

that 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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...