Is it possible to run VBA scripts upon startup with Outlook

Bernie Garwig 0 Reputation points
2025-02-05T16:49:45.4866667+00:00

I am trying to do the following:

Move Emails on a Schedule from one folder to another.

So far, I have the macro that moves the emails. However, I am not sure how to initiate this automatically. Copilot told me I can make a .vbs that with MS Scheduler will be able to move the emails on a schedule

Dim objOutlook

outlookApp.Session.Logon

outlookApp.Application.Run "MoveEmails"

Set outlookApp = Nothing.

I get error code 800A01B6 object doesn't support this property or method. Is there any way to move emails on a schedule, either by scheduled task or other means?

Office
Office
A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.
1,891 questions
Outlook
Outlook
A family of Microsoft email and calendar products.
4,427 questions
Office Development
Office Development
Office: A suite of Microsoft productivity software that supports common business tasks, including word processing, email, presentations, and data management and analysis.Development: The process of researching, productizing, and refining new or existing technologies.
4,226 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Hornblower409-4652 75 Reputation points
    2025-02-06T08:25:43.2033333+00:00

    Copilot was hallucinating. Unlike other Office apps, there is no "Application.Run" method in Outlook.

    As far as I know, Outlook Security has pretty much blocked the ability to run a Macro from outside of Outlook. One method I've used in the past, was to add the Macro to the Quick Access Toolbar and then use a scripting tool like AutoIt to "Send" keystrokes to a running, visible, Outlook session to execute the Macro. e.g. "{Alt Down} {Alt Up} 1" will execute the first item on the QAT.

    You might be better off using something other than an Outlook macro. Any office app that lets you use CreateObject("Outlook.Application") (e.g. Excel) can then do pretty much the same thing your Macro did, using almost identical VBA code. There are lots of other options. Scripting languages that support Outlook Automation (e.g. AutoIt) and C# using the Outlook Interop libraries.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.