View Single Post
  #8   Report Post  
Posted to microsoft.public.excel.programming
Old Man River Old Man River is offline
external usenet poster
 
Posts: 12
Default Scheduled Task Fails running Code to send Outlook Mail from Ex

Oh for the days of white coats, punched cards, paper tape, drum drives and
core!

Got a result but it doesn't hep me much Get the following error:
"Error # 70 was generated by VBAProjectPermission denied"
on this code line.
Set OutApp = CreateObject("Outlook.Application")
Will start a new thread and give you a ticK


"Joel" wrote:

You beat me. I only have 31 years of experience but have always been in the
game. I think you need to get the namespace which associates the user login
to the mail pst file.

Sub ChangeCurrentFolder()
Dim myolApp As Outlook.Application
Dim myNamespace As Outlook.NameSpace
Set myolApp = CreateObject("Outlook.Application")
Set myNamespace = myolApp.GetNamespace("MAPI")
Set myolApp.ActiveExplorer.CurrentFolder = _
myNamespace.GetDefaultFolder(olFolderCalendar)
End Sub


"Old Man River" wrote:

Thanks Joel

Have scheduled the task with all the right things such as run when I'm not
logged in and save my password.

Am going to try and set this up as a very simple Auto_Run macro add some
debug code as suggested and try to find where it's going wrong.

My feelings are that it is grabbing some resource and not letting go as the
first time the code is hit I think the task fails to complete.

Will post back if I get any clearer inication but if anyone has any ideas
don't be shy. A programmer with 40 years experience but who's been out of the
game for 6 years ain't to old to learn new tricks.

"Joel" wrote:

When scheduling the task make sure it is run with Alan's crudentials.

You can add debugging statments to help isolate the problem(s). You can add
a on Error statement ito the code that will produce an error log
Original Source: The Code Cage Forums
Scheduled Task Fails running Code to send Outlook Mail from Excel.

On Error goto 100




100 If Err.Number < 0 Then
Msg = "Error # " & Str(Err.Number) & " was generated by " _
& Err.Source & Chr(13) & Err.Description
Open "C:\Users\Alan\Documents\HSC\Fence Check\Batch.log" _
For Output As #1

Write #1, msg
Close #1

End If

"Old Man River" wrote:

I am trying to run this subroutine from an Excel Macro in a Scheduled job.