Command line parameters into a macro

  • Thread starter Thread starter Donemowe
  • Start date Start date
D

Donemowe

Hi,

Is there any way I can pass some parameters into a macro? The macro is
currently executing correctly except that I am hard coding a variable that I
want passed into it.

Ideally I'd like to pass it in from a hyperlink - something like
"myspreadsheet.xls?paramvalue=12345".

Does anyone know if this is possible?

Regards,

Tony
 
Hi Tony,
Take a look at Chip Pearson's page at the differences
between Macros and Functions:

Macros And Functions (Differences)
http://www.cpearson.com/excel/differen.htm

I will assume you have the distinction correct because you
said you had to hard code the values into the macro,
and the purpose of a function is generally to use parameters.
But please read the above anyway. It will answer at least
one part of question that you asked..

You can use an inputbox in a macro to obtain values
see Prefix160 and other macros using InputBox in
http://www.mvps.org/dmcritchie/excel/join.htm
http://www.mvps.org/dmcritchie/excel/code/join.htm

Syntax
InputBox(prompt[, title] [, default] [, xpos] [, ypos] [, helpfile, context])

example with prompt, title, and default value::
Dim nRowsX as String
nRowsX = InputBox("Specify number of rows (including Cell A1)," _
& Chr(10) & "number of columns will be same as number of rows)" _
& " suggesting " & nRows, _
"Selection of Number of rows to Rotate", nRows)
If nRowsX = "" Then GoTo done 'Check for cancellation

You can have a short macro call another macro using
parameters, but you cannot invoke a macro and pass it
parameters. Example
XL2HTML, XL2HTMLs, XL2HTMLx, XL2HTMLa all call XL2HTML_MAIN
in http://www.mvps.org/dmcritchie/excel/code/xl2htmlx.txt

When you use a real ISP as your return address, anyone who tries
to reply to you will send a response essentially to the server administrator,
who will either have to figure out who it is for or in the case of Microsoft
simply reject it.
 
Let me try to rephrase my statement:
You can have a short macro call another macro using
parameters, but you cannot invoke a macro and pass it
parameters.

You can have a short macro call another macro using
parameters from your code.

You cannot invoke a macro from the worksheet.
 
Back
Top