Open Outlook Address book in Outlook 2013 from MS Access

sydc

Registered User.
Local time
Today, 13:09
Joined
May 28, 2010
Messages
10
Hi,
I have written an Access database for my local flying club for membership. Within this database is a form which is used to e-mail pre-defined reports to members. On this form is a button called 'btnTo' which is used to open the Outlook address book, the code under the button has worked without probelms for the last two to three years but I have been asked to migrate this to Office 2013 which I have completed apart from the code under the button 'btnTo' which produces an error when actioned using Outlook 2013.
Is there another way to re-write the code so that it works both for Outlook 2010 and Outlook 2013 when using Access 2010/2013.
The database was originally written using Office 2010 products.
Code for opening address book from Access using command button 'btnTo'.


Code:
'Routine to open MS Outlook address book'

Private Sub btnTo_Click()
        On Error GoTo Err_btnTo_Click
        
    Dim oApp As Outlook.Application
    Dim oCB As Office.CommandBar
    Dim oCBTools As Office.CommandBarPopup
    Dim oCBSelect As Office.CommandBarButton
    Dim oInsp As Outlook.Inspector
    Dim oCont As Outlook.MailItem
    
            Set oApp = New Outlook.Application
            oApp.GetNamespace("MAPI").Logon "", "", False, True
        
         
    Set oCont = oApp.CreateItem(olMailItem)
    Set oInsp = oCont.GetInspector
    oInsp.Display vbModeless
    oInsp.WindowState = olNormalWindow
        oInsp.Left = -10000 'Set the Inspector off screen. -10000
                        'Set to 250 to return it to viewable location
    
    Set oCB = oInsp.CommandBars("Menu Bar")
    Set oCBTools = oCB.Controls("&Tools")
    Set oCBSelect = oCBTools.Controls("Address &Book...")
    oCBSelect.Execute
   
       'Populate recipient field on e-mail form ('txbTo') from address book
       Me!txbTo.Value = oCont.To
          
    oCont.Close olDiscard
    Set oCont = Nothing
    Set oCBSelect = Nothing
    Set oCBTools = Nothing
    Set oCB = Nothing
    Set oApp = Nothing
    
Exit_btnTo_Click:
    Exit Sub
    
Err_btnTo_Click:
    MsgBox Err.Description
    Resume Exit_btnTo_Click
    
End Sub

Kind regards,
Syd.
Please go easy on me I am new to the forum.:)

'SOLVED'
Recoded project.
 
Last edited:

Users who are viewing this thread

Back
Top Bottom