Jump to content

Run Outlook Macro from Autoit Script


Recommended Posts

Hello 

I would like to Run Outlook macros from Autoit every 1 hour, below script unable to run macros.

While 1
 
    $Minute = Random(1,59,1)
        Do 
    
            Sleep(1000)    
 
        Until @Min = $Minute   
     
    ; do whatever    
    ; Since we want it to run randomly once an hour, we need to calculate how much time is left before the hour is up, and sleep that length of time.
        $s = ((60 - $Minute) * 60) * 1000     
            Sleep($s)
        $oOApp = ObjCreate("Outlook.Application")
    $oOApp.Run("SaveAttachments") ; Run Outlook Macros

WEnd

 

 

Link to comment
Share on other sites

  • Moderators

@sumandevadiga as is usual, you're not providing enough information. What does the macro do exactly? There is a well-defined library for Outlook in AutoIt; there may be a better way to accomplish what you're after, but it is impossible to tell with little to no description.

"Profanity is the last vestige of the feeble mind. For the man who cannot express himself forcibly through intellect must do so through shock and awe" - Spencer W. Kimball

How to get your question answered on this forum!

Link to comment
Share on other sites

Hello Logan

Sorry for incomplete information, actually i was looking only for the autoscript which can execute the outlook macros, likewise i i used below script to run excel macros.

Basically i have a Macro in Outlook which i would like to run every hour to check specific subject email and fetch the details and save in excel, so macro is ready only i required a autoit script which will active this macro every hour.

let me know if more information required.

#include <Excel.au3>
#include <MsgBoxConstants.au3>
$oExcel = _ExcelBookOpen ("C:\Test1\Test.xlsm")
$oExcel.Run("SaveWorksheetsAsCsv")
_ExcelBookClose($oExcel)
 

 

Link to comment
Share on other sites

The Outlook application object does not provide a Run method.

Object Model for Outlook 365: https://msdn.microsoft.com/en-us/vba/outlook-vba/articles/application-object-outlook

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Perhaps you need to think about this differently.

I see a functional split.

(a) the scheduler

(b) the Outlook macro

First, make the scheduler to run the way you want.  Random etc.  There are tools out there, or use the Windows Task Scheduler.

This scheduler then triggers the Outlook script.  This can be compiled as an EXE, so when ever the scheduler launches it, it runs like a little app, doing what you want.  Or, if you want to include the scheduling, a service may work better.

Perhaps the point is that you can achieve your stated goal, but you will need to do the work.  There is no out of the box solution for what you want.

:)

 

Skysnake

Why is the snake in the sky?

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...