Posted to microsoft.public.excel.programming
|
|
Run add-in code when Excel starts
once instantiated...
xl.visible = True
"RB Smissaert" wrote in message
...
Got Excel to start with this:
AddScheduleTask "5:00", _
"""C:\Program Files\Microsoft
Office\Office10\Excel.exe""", , , True, False
But started the Windows installer and popped up a dialog.
If I set RunInteractive = False it will run invisible and I don't want
that.
It doesn't seem this is a simple thing to do.
RBS
"Patrick Molloy" wrote in
message ...
its much easier if your scedul;er riuns a vb script program
very simple to do.
open notepad, add this example,
option explicit
dim passparam
dim xl as object
dim wb as object
Set xl = CreateObject("Excel.Application")
xl.workbooks.open "s:\Myworkbook.xls"
if wscript.arguments.count = 0 then
' no sub to call
else
passparam = Wscript.Arguments.Item(0)
select case passparam
case "A"
wb.run "MySub","A"
case "B"
wb.run "MySub","X"
Case else
wb.run "someothersub"
end select
end if
now save the text file with a VBS extension, eg MyExcelTest.VBS
VB Scripts are built as part of XP . example
put MSGBOX "hello world!" in notepade & save to your desktop sa HW.VBS
now double click the HW.VBS icon on the desktop...hey presto!
With the code sample, you could call this like:
MyExcelTest.VBS "A"
in which case the pass parameter is the letter A. the rest is self
evident I
think
HTH
Patrick Molloy
Microsoft Excel MVP
"RB Smissaert" wrote:
Using Excel 2000 to 2003.
I would like to run a Sub in an Excel add-in when Excel starts, but only
when
this is specified with a commandline parameter.
Excel will be started by the Windows Task Scheduler.
What I could do is add a workbook to the Scheduler commandline and put
some
code in this workbook that will run with the Open event. This is a bit
clumsy though
as I don't need the extra workbook.
Thanks for any advice.
RBS
|