ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Scheduled task "Error # 70 was generated by VBAProjectPermission (https://www.excelbanter.com/excel-programming/436104-scheduled-task-error-70-generated-vbaprojectpermission.html)

Old Man River

Scheduled task "Error # 70 was generated by VBAProjectPermission
 
"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.



Barb Reinhardt

Scheduled task "Error # 70 was generated by VBAProjectPermission
 
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
--
HTH,

Barb Reinhardt



"Old Man River" wrote:

"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.



Old Man River

Scheduled task "Error # 70 was generated by VBAProjectPermis
 
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.

"Barb Reinhardt" wrote:

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
--
HTH,

Barb Reinhardt



"Old Man River" wrote:

"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.




All times are GMT +1. The time now is 09:30 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com