Opening Outlook from Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I am trying to send an email with an attachment from Access 2007. I ran into
problems with getObject and createObject. The object is "Nothing" even if
Outlook is open. To try and isolate the problem, I created a new database to
do some testing with the following module

Sub test()

Dim objApp As Object
Dim blnOutlookInitiallyOpen As Boolean

On Error Resume Next

blnOutlookInitiallyOpen = True

Set objApp = GetObject(, "Outlook.Application")
If objApp Is Nothing Then
Set objApp = CreateObject("Outlook.Application")
' Outlook wasn't open when this function started.
blnOutlookInitiallyOpen = False
End If

If Err <> 0 Then Beep: _
MsgBox "Error in " & strProcName & " (1): " _
& Err.Number & " - " & Err.Description: _

End Sub

References are
- Visual Basic for Applications
- Microsoft Access 12.0 Object Library
- Microsoft Outlook 12.0 Object Library
- OLE Automation
- Microsoft DAO 3.6 Object Library

I posted the message on an Access Newsgroup and it was suggested that the
issue could be binding. I am not sure I really understand early and late
binding in spite of some technical stuff I have read but it doesn't seem to
change the situation.

I changed
Dim objApp As Outlook.Application
to:
Dim objApp As Object

Still get error 429 - Active X component can't create object.

I turned off Kaspersky AV and it made no difference. Not sure what to try
next.
 
Seems I managed to solve the problem on my own. The answer seemed to be to
run Office Diagnostics in Access 2007. It didn't report any errors but after
running that, suddenly objects were recognised. I had never heard of it
before but found a post on a newsgroup to either run Office Diagnostics in
Office 2007 or Detect and Repair in earlier versions. Thanks to Sue Mosher.
Check
http://www.devnewsgroups.net/group/microsoft.public.office.developer.outlook.vba/topic58421.aspx
 
Back
Top