Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Commandline Arguments
I want to open excel using a template and pass an
argument that can be used in a macro, e.g excel.exe /t template.xlt arg1 Does anyone know if this is possible? |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Commandline Arguments
I don't think so. In fact, when I tried it, excel opened my test template
file--not a new workbook based on the template. Maybe you could save the template as readonly (on the network??), so that it can't be saved. Then put your parm into a text file and have the auto_open/workbook_open retrieve the value from that file. Tim wrote: I want to open excel using a template and pass an argument that can be used in a macro, e.g excel.exe /t template.xlt arg1 Does anyone know if this is possible? -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Commandline Arguments
Thanks for your replies.
I have solved the problem by calling the following vbscript: ' This script will run open excel ' and run a macro based on the contents in a named cell Const XLPATH = "\\PCResources\Templates\Excel\" Const TEMPLATE = 0 Const SHEET = 1 Const RANGE = 2 Const MACRO = 3 Const KEY = 4 Dim MAXKEY Dim app Dim wb Set objArgs = WScript.Arguments If objArgs.count < 5 then MAXKEY = "" Else MAXKEY = objArgs(KEY) End If 'msgbox "Template " & objArgs(TEMPLATE) 'msgbox "Sheet " & objArgs(SHEET) 'msgbox "Range " & objArgs(RANGE) 'msgbox "Key " & MAXKEY ' Launch Excel set app = createobject("Excel.Application") ' Make it visible app.Visible = true set wb = app.workbooks.add( XLPATH & objArgs(TEMPLATE)) wb.Worksheets(objArgs(SHEET)).Range(objArgs(RANGE) ).Value = MAXKEY app.run(objArgs(MACRO)) set wb = nothing set app= nothing ' I hope this is useful -----Original Message----- I want to open excel using a template and pass an argument that can be used in a macro, e.g excel.exe /t template.xlt arg1 Does anyone know if this is possible? . |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Too many arguments | Excel Worksheet Functions | |||
IF-more than 7 arguments | Excel Discussion (Misc queries) | |||
IF-more than 7 arguments in | Excel Worksheet Functions | |||
arguments | Excel Discussion (Misc queries) | |||
Pass cell contents to external program as commandline option | Excel Discussion (Misc queries) |