Results 1 to 5 of 5
  1. #1
    russ0670 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Posts
    21

    ActiveX component can't create object. VBA Sending Email

    I am using the following code but when i run it produces the following error.



    Run-time error '429':

    ActiveX component can't create object.

    then on debug it highlights the line
    Set objOutlook = CreateObject("Outlook.Application")

    I have searched online and already tried a suggestion to ensure that microsoft outlook 14.0 object library is selected in the VBA references.

    Anyone have an idea?

    Code:
    Dim objOutlook As Object
    Dim objMailItem As Object
    Const olMailItem As Integer = 0
    Set objOutlook = CreateObject("Outlook.Application")
    Set objMailItem = objOutlook.CreateItem(olMailItem)
    
     'set the object from template
    Set objMailItem = objOutlook.CreateItemFromTemplate("C:\FastFile\System 3.0\3.0\BLANKTEMP.oft")
    
    
    strEmail = "test@testing.com"
    strSubject = "Test"
    strBody = "Test the Outlook Object"
    strPathAttach = "C:\FastFile\System 3.0\sampleatt.pdf"
    
    
    On Error GoTo err_Error_handler
    
    'set receipient
    objMailItem.To = strEmail
    'set subject
    objMailItem.Subject = strSubject
    'set body content
    objMailItem.Body = strBody
    'Check path and file, then set Attachment
    
    If Len(Dir(strPathAttach)) Then
       With objMailItem.Attachments
          'use parenthisis around the path
          .Add (strPathAttach)
      
       End With
    End If
    
    'sending email
    objMailItem.Send
    
    
     Set objOutlook = Nothing
     Set objMailItem = Nothing
    
    
    exit_Error_handler:
     On Error Resume Next
    
     Set objOutlook = Nothing
     Set objMailItem = Nothing
     
     Exit Sub
     
    
    err_Error_handler:
     Select Case Err.Number
      'trap error 287
      Case 287
       MsgBox "Canceled by user.", vbInformation
      Case Else
       MsgBox "Error " & Err.Number & " " & Err.Description
     End Select
    
    Resume exit_Error_handler

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Cannot find solution for using CreateItemFromTemplate. Everything leads to building the message dynamically with HTML code tags in VBA.

    https://social.msdn.microsoft.com/Fo...rum=outlookdev
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It looks like late binding to me so there should not be a need for any reference to Microsoft Outlook Object Library. Having said that, is it available in the machine that is causing you trouble? If you see it as a reference in your development machine that indicates that Outlook is installed on your development machine. However, this is not a guarantee that Outlook is installed on every other machine.

    Is Outlook installed on the machine giving you trouble? If you add the reference to your project and then try to open your project on the machine giving you trouble, do you get a warning that there is a missing reference?

  4. #4
    russ0670 is offline Novice
    Windows Vista Access 2007
    Join Date
    Jan 2010
    Posts
    21
    SOLVED

    Found it was because Access was open as administrator and outlook was not. Set both to normal and fires perfectly.

    Also works if both set to open as administrator. go figure.

    thanks guys for your help.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Do you mean Access was open in exclusive mode? I am not sure what you mean by 'administrator' for Access or Outlook.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. ActiveX failure to get Excel object
    By Monterey_Manzer in forum Access
    Replies: 3
    Last Post: 09-13-2013, 09:15 AM
  2. Replies: 5
    Last Post: 05-25-2011, 02:34 PM
  3. Replies: 2
    Last Post: 03-03-2011, 12:48 PM
  4. Replies: 0
    Last Post: 10-20-2009, 01:10 PM
  5. ActiveX componet can't create object
    By quanmay35 in forum Access
    Replies: 1
    Last Post: 05-26-2009, 05:27 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums