![]() |
Excel to Schedule Task in Outlook
I get this message:
Automation error. The specified module could not be found. When I run this code: Sub CreateTask() Dim objApp As Outlook.Application Dim objTask As Outlook.TaskItem Set objApp = CreateObject("Outlook.Application") Set objTask = objApp.CreateItem(olTaskItem) With objTask .Subject = "Subject" .StartDate = CDate(ProximaFechaAcumulada) - CDate(15) .DueDate = CDate(ProximaFechaAcumulada) .Importance = olImportanceHigh .Body = "Body" 'Here I need Right to Left .Save .ReminderSet = True End With End Sub It fails on this line: Set objApp = CreateObject("Outlook.Application") I dont understand this behavior. I have checked the Reference to MS Outlook Object Library on my system and Im having a problem with the code. I tried to create a small tool to simplify things in our office, but it just doesnt seem to work right. When I go to a few other machines in the office it runs fine. I cant tell whats going on. Perhaps there is some kind of esoteric setting that is different on my workstation... Id appreciate it if someone could share some insight. Regards, Ryan-- -- RyGuy |
Excel to Schedule Task in Outlook
By chance do you have Outlook running when trying to run this macro? If so,
the code will fail because only one instance of OUtlook can be open at any time. Instead, try this code: Sub GetOutlookReference() 'Outlook objects Dim olApp As Outlook.Application 'Obtain a reference to Outlook On Error Resume Next Set olApp = GetObject(, "Outlook.Application") 'If Outlook isn't running, start it and remember If olApp Is Nothing Then Set olApp = CreateObject("Outlook.Application") End If ' If Outlook still isn't running, Outlook cannot open or is not installed If olApp Is Nothing Then Call MsgBox("Outlook could not be opened. Exiting macro.", _ vbCritical, Application.Name) End If End Sub I cannot test this code since we do not have Outlook at work, but if you still need help, I can test it at home. Otherwise, here's a link to the Outlook VBA Newsgroup: http://msdn.microsoft.com/newsgroups.... outlook.vba Matthew Pfluger "ryguy7272" wrote: I get this message: Automation error. The specified module could not be found. When I run this code: Sub CreateTask() Dim objApp As Outlook.Application Dim objTask As Outlook.TaskItem Set objApp = CreateObject("Outlook.Application") Set objTask = objApp.CreateItem(olTaskItem) With objTask .Subject = "Subject" .StartDate = CDate(ProximaFechaAcumulada) - CDate(15) .DueDate = CDate(ProximaFechaAcumulada) .Importance = olImportanceHigh .Body = "Body" 'Here I need Right to Left .Save .ReminderSet = True End With End Sub It fails on this line: Set objApp = CreateObject("Outlook.Application") I dont understand this behavior. I have checked the Reference to MS Outlook Object Library on my system and Im having a problem with the code. I tried to create a small tool to simplify things in our office, but it just doesnt seem to work right. When I go to a few other machines in the office it runs fine. I cant tell whats going on. Perhaps there is some kind of esoteric setting that is different on my workstation... Id appreciate it if someone could share some insight. Regards, Ryan-- -- RyGuy |
All times are GMT +1. The time now is 07:28 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com