Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default 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   Report Post  
Posted to microsoft.public.excel.programming
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?
.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Too many arguments Nick Wakeham Excel Worksheet Functions 2 March 18th 09 06:19 PM
IF-more than 7 arguments Carolina Excel Discussion (Misc queries) 3 May 20th 08 10:38 PM
IF-more than 7 arguments in Carolina Excel Worksheet Functions 2 May 20th 08 08:46 PM
arguments gemini0662 Excel Discussion (Misc queries) 9 July 13th 06 03:48 PM
Pass cell contents to external program as commandline option Research freak Excel Discussion (Misc queries) 1 September 16th 05 11:03 PM


All times are GMT +1. The time now is 09:43 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"