Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Outlook Macro to run via VBScript with Windows Task Scheduler

Status
Not open for further replies.

supportsvc

Technical User
Jan 24, 2018
249
US
This does not work.
I get

Object doesn't support the property or method:
'myOutlook.SendNewestFiles'

Code:
Set myOutlook = CreateObject("Outlook.Application")
myOutlook.ThisOutlookSession.SendNewestFiles or myOutlook.SendNewestFiles
myOutlook.Quit
Set myOutlook = Nothing
as well as the switch for Office 2016 in Task Scheduler
Code:
"C:\.... Outlook.exe" /m ThisOutlookSession.SendNewestFiles

Anyone know the correct VBS code to launch and run an Outlook Macro?
Or another way?

I tried the Application_StartUp but do not want to have it run every time Outlook is opened.
Otherwise have to open in Safe Mode to use Outlook regularly.

 
supportsvc,
don't search for solution randomly. Each of office applications has its own set of switches, this also depend on office version. For outlook, /m adds e-mail name to the item, so no way to run macro with it.
Outlook has no direct way to run its macro remotely.
I think that you have only two possibilities:
1. transfer the code from outlook and adapt it in VBS, as I suggested in VBA forum. You will have the script a bit longer, but will do the same what the code in outlook does,
2. try to create another "otm" file with outlook vba project. Put your macro there and call it in the Application_StartUp event procedure in this project. Open outlook from VBS with the alternative vba project using /altvba switch, see ms office support for details.

combo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top