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/default.aspx?dg=microsoft.public.office.dev
eloper.outlook.vba
Matthew Pfluger
> I get this message:
> Automation error. The specified module could not be found.
[quoted text clipped - 32 lines]
> Regards,
> Ryan--
ryguy7272 - 25 Jan 2008 21:01 GMT
Thanks for looking at this Matt!
If I open Outlook and run your coed, nothing happens. If I close Outlook
and run your code, I get an error message: 'Outlook could not be opened.
Exiting macro'. I guess olApp = Nothing...
This is the code that I am trying to run now:
Sub GetOutlookReference()
'Outlook objects
Dim olApp As Outlook.Application
'Obtain a reference to Outlook
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
'*********************************************
Dim objApp As Object
Dim OutTask As Object
Set objApp = CreateObject("Outlook.Application")
Set OutTask = objApp.CreateItem(olTaskItem)
With OutTask
.StartDate = Range("C1")
.DueDate = Range("C2")
.Importance = olImportanceHigh
.Display
.ReminderSet = True
End With
'*********************************************
'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
Basically, nothing happens when the code fires.
Not sure what to make of all this. Got any other thoughts?
Regards,
Ryan---

Signature
RyGuy
> 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
[quoted text clipped - 68 lines]
> > Regards,
> > Ryan--
JP - 25 Jan 2008 21:40 GMT
Try this, it is a full replacement for your code. i.e delete your
existing code and replace it with this.
Sub GetOutlookReference()
Dim olApp As Outlook.Application
Dim OutTask As Outlook.TaskItem
On Error Resume Next
Set olApp = GetObject(, "Outlook.Application")
If Err.Number <> 0 Then
Set olApp = CreateObject("Outlook.Application")
End If
On Error GoTo 0
If olApp Is Nothing Then
MsgBox "Cannot start Outlook.", vbExclamation
Exit Sub
End If
Set OutTask = olApp.CreateItem(olTaskItem)
With OutTask
.StartDate = range("C1")
.DueDate = range("C2")
.Importance = olImportanceHigh
.Display
.ReminderSet = True
End With
End Sub
HTH,
JP
On Jan 25, 4:01 pm, ryguy7272 <ryguy7...@discussions.microsoft.com>
wrote:
> Thanks for looking at this Matt!
>
[quoted text clipped - 127 lines]
>
> - Show quoted text -