Results 1 to 12 of 12
  1. #1
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171

    Email from access form transfered to different version OS

    I have developed an application where I email a document via a form. I have done my development on Windows 10 system with Access and outlook level 2016. I am attempting to implement it on a corporate system running Access and Outlook 2010. When I execute the first code I get and error saying 'Can't find Project or library'. The reference list in tools shows a 'Missing Microsoft Outlook 16.0 Object library'. This library does not exist in the reference list and I did not find this object for any other level such as 'Microsoft Outlook 10.0. There must be a way around this?

  2. #2
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    Older or newer versions of references have to be available to all generations of a db or Office install. In other words, you set a reference to 16.0 but it's not likely available to a computer running an older Office version. The older one is more likely available to the newer version in a corporate environment. You'll have to figure out where they are and make them available, or you could try late binding in your code.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    I have no idea where to look for them or how to make them available. Nor do I know anything about late binding.

    Thanks

  4. #4
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    You'll have to decide on whether to make the new references available to the old, or vice-versa. Or have 2 apps, one for each group of users, in which case you don't have to do any of the following.

    Open the db. press Alt+F11. In the vb editor, choose Tools>References. Select a reference from the list and the path it thinks is correct will be displayed in the References dialog form near the bottom. Most likely you won't be able to see the entire path (and the form is not expandable) but it should give you an idea of where to start a file search for that file. The file would have to be distributed along with the front end of your db. That's about the best I can suggest, other than Googling late binding.

  5. #5
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    I am out of my league here. It would help to see sample code for the early binding.

    If I were to solve this with the two application method how much of the application must be redeveloped on the host system?

    Thanks

  6. #6
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Can you save the db in Access 2010? Not sure if that would resolve anything. As Micron said, try to find that "Microsoft Outlook 16.0 Object library" file on your harddrive and then copy it to a network folder or the local folder where the program will reside. And in your program, uncheck the Outlook 16 reference and add the one that is in that local folder.

  7. #7
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    I am out of my league here. What part of my previous post do you need help with?

    Late binding means that an object is declared as "Object" for example, instead of being more specific about the type of object. This method requires no reference to a type library and can be used if the object supports late binding:
    Dim oExcel As Object
    Set oExcel = CreateObject("Excel.Application")

    Early binding requires a type library (reference set in vb editor Tools > References):
    Dim oExcel As Excel.Application
    Set oExcel = CreateObject("Excel.Application")

    The following is based on not having seen any of your code.
    Early binding is likely what your code uses. I'm fairly certain that code using late binding will still cause your error if the library reference is checked but cannot be found, so you would have to uncheck it to prevent the error message if using late binding. Late binding causes code to run slower and does not provide Intellisense (the automatic completion of form/report object control references or the syntax and parameters for built in functions) when you are typing. You'll have to weigh that against the upside of late binding.

    Your easiest solution is probably to alter only the procedures that use Outlook so that you use late binding. Know also that since you developed in 2016 and I gather that older Access versions will be using this db, you might have used 2016 features that would cause issues on a pc using Access 2007 but problems haven't arisen yet.

    I'm using Office 12 at home, so any Access code invoking the Outlook application requires a reference to Microsoft Outlook 12 type library which the References dialog box (in the aforementioned vb editor) shows as being located at
    C:\Program Files\Microsoft Office\Office12\MSOUTL.OLB
    I don't recall ever having this problem because at work, everyone was always on the same version of Office so the references only had to be updated. I don't see why finding and including the type library you need wouldn't work if it was part of your distribution package. Keep a backup copy of your working db before you go altering code.
    Last edited by Micron; 03-07-2017 at 10:17 AM. Reason: clarification

  8. #8
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    Following is the code I am using. It works well in Access 2016.
    Private Sub BtnEmail_Click()

    'Check for email address
    If IsNull([EmailAddress]) Then
    MsgBox "Enter Email Address"
    Me.EmailAddress.SetFocus
    Else: GoTo Continue
    End If
    Exit Sub

    'Send email
    Continue:
    Dim FileName As String
    Dim FilePath As String
    Dim oOutlook As Outlook.Application
    Dim oEmailItem As MailItem


    FileName = Me.DocumentTitle
    FilePath = Me.ImagePath


    If oOutlook Is Nothing Then
    Set oOutlook = New Outlook.Application
    End If

    Set oEmailItem = oOutlook.CreateItem(olMailItem)

    With oEmailItem
    .To = Me.EmailAddress
    .Subject = "Document From Greene Memorial Archive System"

    .Attachments.Add FilePath
    .Send
    End With

    Set oEmail = Nothing
    Set oOutlook = Nothing

    MsgBox "Email has been sent to " & Me.EmailAddress
    DoCmd.Close acForm, "frmSearch"
    DoCmd.Close
    DoCmd.OpenForm "frmMenu"
    End Sub

    What code needs to be changed to use late binding. I am still trying to get my mind around the whole concept..
    I appreciate your patience and help

  9. #9
    Bulzie is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    Nov 2015
    Posts
    1,511
    Did you try removing(uncheck) that reference to MS Outlook, save and compile the code, does it give an error?

  10. #10
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    As I mentioned, late binding will require you to remove the missing reference. Yes, it will generate an error if the reference cannot be found on a computer AND you are using early binding, which you are. In future, please use code tags and indentation to make code easier to read. I took the liberty of re-writing your code in a way that I think will work. Plus I introduced some of my own preferences, such as grouping declarations and added an error handler. You'll notice I removed the Else and GoTo as such direction is not required if you grasp the flow as written.

    Code:
    Private Sub BtnEmail_Click()
    Dim FileName As String
    Dim FilePath As String
    Dim oOutlook As Object
    Dim oEmailItem As Object
    
    On Error GoTo errHandler
    FileName = Me.DocumentTitle
    FilePath = Me.ImagePath
    
    'Check for email address
    If IsNull([EmailAddress]) Then
     MsgBox "Enter Email Address"
     Me.EmailAddress.SetFocus
     Exit Sub
    End If
    
    'Send email
    If oOutlook Is Nothing Then 
     Set oOutlook = New Outlook.Application
     Set oEmailItem = oOutlook.CreateItem(olMailItem)
    End If
    
    With oEmailItem
     .To = Me.EmailAddress
     .Subject = "Document From Greene Memorial Archive System"
     .Attachments.Add FilePath
     .Send
    End With
    
    MsgBox "Email has been sent to " & Me.EmailAddress
    DoCmd.Close acForm, "frmSearch"
    DoCmd.OpenForm "frmMenu"
    DoCmd.Close
    Exit Sub
    
    exitHere:
    Set oEmailItem = Nothing 'OEmail was not a declared object or variable
    Set oOutlook = Nothing
    
    errHandler:
    MsgBox "Error " & Err.Number & ": " & Err.Description
    Resume exitHere 'if you want to close forms regardless of a run time error, you can move the
    'close commands to the exitHere block. Note that if you mis-spell or rename form, a continuous 
    'error loop will occur unless you alter the errHandler block to trap for that particular error.
    
    End Sub
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  11. #11
    WAVP375 is offline Competent Performer
    Windows 8 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Dayton Ohio
    Posts
    171
    I'll work on it

    Thanks

  12. #12
    Micron is offline Very Inert Person
    Windows 7 32bit Access 2007
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    13,372
    BTW, when you get this working you are likely going to get the security prompt and will have to click ok to send each email. Not sure if you're aware of that.

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

Similar Threads

  1. Replies: 2
    Last Post: 05-23-2016, 01:28 PM
  2. Replies: 6
    Last Post: 02-18-2016, 10:15 AM
  3. Replies: 2
    Last Post: 02-11-2014, 07:40 PM
  4. Replies: 4
    Last Post: 05-30-2012, 07:00 AM
  5. Replies: 5
    Last Post: 01-18-2012, 12:46 PM

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