Scheduled task "Error # 70 was generated by VBAProjectPermission

O

Old Man River

"Error # 70 was generated by VBAProjectPermission denied"

Is generated when the statement
Set OutApp = CreateObject("Outlook.Application")

Is executed in a scheduled task but not when the Auto_Open macro in excel is
triggered any other way.

What do I need to do to enable me to get permission.
 
B

Barb Reinhardt

You may want to check if an instance of outlook is already running.

Try something like

Set OutApp = nothing
on error resume next
Set OutApp = GetObject(, "Outlook.Application")
On error goto 0

if OutApp is nothing then
Set OutApp = CreateObject("Outlook.Application")
end if
 
O

Old Man River

Thanks Barb but does not help for several reasons.
Outlook is a single instance programme so CreateObject will return a
currently running instance if there is one or start outlook if it isn't
running.
Outlook is running on the desktop at all times.
Code only fails when run via a scheduled task.

If I do use GetObject I recieve a different message viz:
Error # 429 was generated by VBAProjectActiveX component can't create object

I think this is to do with preventing code running in the background sending
emails but I want to be able to give my code permission.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top