View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Tim[_16_] Tim[_16_] is offline
external usenet poster
 
Posts: 2
Default 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?
.