View Single Post
  #12   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,

I think I tried that one, but tried it again and indeed didn't run again.
I am not sure why this is as the string in the Run box looks the
same as a string that is manually set and does run.
Maybe I need to alter the underlying file or registry setting that
stores the information about the tasks.
This turns out the be a real nuisance and it is a shame as the .dll
file works otherwise really well.
Still not given up.

RBS



"Bob Phillips" wrote in message
...
An other attempt :-)

.ApplicationName = Application.Path & "\Excel.exe"
.CommandLine = """C:\Schedule.xls"""

--

HTH

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


"RB Smissaert" wrote in message
...
Yes, tried that one, but didn't work.
It seems it needs the quotes around the
full application path.

RBS


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

Not tested it myself, but was one of your attempts?

.CommandLine = """C:\Schedule.xls"""


--

HTH

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


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