View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
RB Smissaert RB Smissaert is offline
external usenet poster
 
Posts: 2,452
Default Run add-in code when Excel starts

Bob,

Yes, I could and that might be the easiest.

I have one other problem.
I set the task scheduler via a dll written by Eduardo Morcillo:
http://www.mvps.org/emorcillo/vb6/grl/index.shtml

This Sub makes the task and it looks fine, but the task can't run:

Sub test()

Dim oSchedule As TaskScheduler2.Schedule
Dim oTask As TaskScheduler2.Task
Dim oTrigger As TaskScheduler2.Trigger

Set oSchedule = New Schedule
Set oTask = oSchedule.CreateTask("ReportSchedule")
Set oTrigger = oTask.Triggers.Add

With oTrigger
.TriggerType = Once
.BeginDay = "28/12/2004"
'.EndDay = "30/12/2004" 'this doesn't seem to do anything
.StartTime = "12:48:00"
.Update
End With

With oTask
.ApplicationName = "Excel.exe"
.CommandLine = "C:\Schedule.xls"
.WorkingDirectory = Chr(34) & Application.Path & Chr(34)
.Flags = RunOnlyIfLoggedOn
'.Flags = DeleteWhenDone 'doing this will clear the previous flag
.Save
End With

End Sub

The reason is the string in the Task Scheduler Run textbox.
This string will be:
C:\PROGRA~1\MICROS~2\Office10\EXCEL.EXE C:\Schedule.xls
with the above code.
If I alter this manually to:
"C:\PROGRA~1\MICROS~2\Office10\EXCEL.EXE" "C:\Schedule.xls"
It will run.
How though do I get this string with my code?
Tried all kind of constructions, but nil works.

Any ideas?


RBS


"Bob Phillips" wrote in message
...
RB,

Alternative suggestion. Could you set an environment variable and test
that
in the add-in?

--

HTH

RP
(remove nothere from the email address if mailing direct)


"RB Smissaert" wrote in message
...
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