Schedule Outlook 2003 Macro - vba

I have an Outlook 2003 macro written in VBA.
I would like to schedule it so that it automatically runs at a certain time, say 01:00. The PC is always logged on.
I couldn't find anything which suggests how to do this.

You could create a scheduled task on the PC to run daily at the specific time, and use the Outlook Command Line Switch to start the program and call your macro e.g:
"C:\Program Files\Microsoft Office\Office11\Outlook.exe" /autorun macroname
Update:
You may be able to use an API call to start a timer to run in the background of outlook, you could combine this with the VB Now() command to get the current time and if greater than your scheduling time you could trigger your macro, the API example can be found here:
http://www.outlookcode.com/threads.aspx?forumid=4&messageid=22831

http://support.microsoft.com/kb/237913/EN-US
This article says it can't be done unless you rewrite it to use CDO.
Sorry.

Related

Excel vba macro to download a file automatically when it's added to a Sharepoint site

I am running an excel macro, it downloads some files from SharePoint. It's working fine but my problem is, Everytime i need to check if the file exists there or no then i download it.
Is there a possibility to add a condition when the file is added on SharePoint then the macro will run automatically. Because the reports are uploaded in different times by other users for example one day at 9 am, another day 11 am, another day at 1pm... and now i am checking everyday many times on the sharepoint site if the report was added or no before i run my macro.
I want to avoid this and link somehow the sharepoint site to my macro.
For example for the reports i receive on Outlook i created a macro when i receive an email with attachment containing a specific name it will download automatically. I want something similar on Sharepoint without checking everytime on Sharepoint if the other users uploaded their reports or not.
Any suggestion please ?
Assuming that you are using SharePoint 2013 OnPremise you can write an ItemAdded event receiver which will execute your macro (you can do this only if you are allowed to deploy code to SharePoint).
You could also write a Service / Job that will run every 5-10 minutes and check which files have been added in the last 5-10 minutes (this frequency will depend on what is the urgency for executing the macro), download the file and then execute the macro on those.
Irrespective of the environment this code could run directly from your local machine if you have no good place to host it.

Running a macro via task scheduler in Windows server 2012

We have created a macro to run in MS access (Office 365) on windows server 2012 so that it runs script that creates and sends emails via MS outlook. We can run the macro from inside MS Access but we cannot get windows task scheduler to automatically schedule this process. What we are doing is creating invoices for our customers automatically using MS Access. The macro works perfectly if we execute it within the open file. It creates all the emails with an invoice attached as a PDF which is then sent via outlook to our customers. This is all done with one click of the macro. But we cannot get this process to schedule via windows task scheduler. Can anyone help?
I am answering my own question as the comments don't allow enough info to be posted.
We have finally managed to do this using the suggestion in one of the above comments to use Outlook reminders rather than task scheduler.
This solution involves setting up a task and scheduled reminder in OUTLOOK.
The recurrent schedule for the reminder in Outlook acts as a replacement for Task Scheduler.
We categorised the reminder to aid the exact identification. (For task add new category and give it a name)
The VBA script in Outlook is triggered by identifying the reminder category and the MSAccess macro is initiated which sends the emails then closes the Access application. This is done on a set scheduled recurrent basis as set for this Outlook reminder task.
The only issue we had was with the following line
mydb.Application.Run "MacroName"
the resulting error was rectified by
mydb.DoCmd.RunMacro “MacroName”
We now have a method of scheduling which works.
It would seem that when an Access VBA script, which includes sending an email is called from an OUTLOOK scheduled script it has no problem in completing the task, whereas, the exact same script actioned through Task Scheduler just does not complete.
Hope this helps others.

Can you schedule periodic data imports in VBA?

I have a VBA function that, when invoked via a button on a sheet, extracts a .csv file from a website and imports it into my workbook. The problem is the file is uploaded in different time intervals during the day, so I have to periodically check the website.
Is there a way in VBA that I can schedule when a function is invoked?
You can use the Application.OnTime() method which will allow you to schedule a Macro for a specific time amongst other settings. However you're probably best using VB Script or similar.
It's also important to note that the workbook would need to be open the entire time if you are going to use VBA, whereas a VBS file will run silently and can be triggered to run at startup.
If you're proficient enough with VBA then you shouldn't have a problem writing VBS.

Windows Task Scheduler running an Excel VBA script

I have a VBA script in Excel that I wish to run every morning. I want to use the Windows task scheduler to run the VBA script.
I currently use windows task scheduler to run an automated MATLAB process. I have done this by putting the path of the MATLAB exe in the Program/script box and putting other parameters in the Add arguments & Start in text boxes. Is it possible to do something similar with Excel & if so how?
I have seen lots of people mention writing a VBA script which I do not wish to do.

how to automatically run a macro at a given hour

I'm wondering if anyone here has experience with setting up a macro to run automatically at a given time... lets say 5AM.
There are some posts on mr excel but most of what I find is simply OnTime "x time" based code, and I'm unsure how this executes.
Do you have to open the sheet, run the macro and then expect it to run at the given time? Once it is open, will it run every day at that time or can you run it whenever?
You could
1] have Windows task scheduler open your workbook. Please see: http://windows.microsoft.com/en-us/windows7/schedule-a-task
2] and then create a function in your macro that launches your code when the book is opened. See http://www.mrexcel.com/forum/excel-questions/6122-run-macro-open.html for more info.
This seems to be what you want:
How can I Run Excel Files as a task or job?
Use the Windows Scheduler to schedule a task to open up the Excel file. You should then be able to use the Workbook_Open Event to do what you need with the file.