- Enveloper 97 to Outlook 98 AddressBook Hook Instructions - The following instructions will create a custom addressbook hook in Enveloper 97 that will allow access to the Microsoft Outlook 98 AddressBook: 1. With Enveloper 97 installed and properly setup for the current user, open Word 97 and select Tools/Enveloper 97/Customize 2. Select the "Create Custom Hooks" button from the Enveloper Customize dialog box that opens. 3. Make sure that the "Create PhoneBook Hook" checkbox is checked and that the "Create Zip Hook" checkbox is unchecked on the Enveloper Build Custom Hooks dialog box that opens and click the "Create" button. 4. Click the "OK" button on the main Enveloper Customize dialog box to close it. 5. Open the newly created "CustomEnvHooks.dot" template from Enveloper's Envelope path (This is the folder in which Enveloper 97 stores your custom envelope templates and it's generally "C:\Program Files\Microsoft Office\Office\Env".) 6. With the "CustomEnvHooks.dot" template open in Word, hit Alt+F11 to activate the VBA Editor. 7. In the Project window of the VBA Editor, locate the CustomEnvHooks project, expand the modules folder, and double-click on the "CustomEnvHooks" module to view it. 8. Select "References" from the VBA Editor's "Tools" menu and create a reference to the "Microsoft CDO 1.2 Library" or the "Microsoft CDO 1.21 Library" by checking the box in front of this reference in the list of available references and clicking on the "OK" button. Note: If you cannot locate the reference within the list of available references, select the "Browse" button and look for a file named "CDO.DLL" in your "C:\Windows\System" (or "C:\Winnt\System32" if you have Windows NT) folder. 9. Replace the existing "GetPhoneBook()" subroutine with the following code (i.e. just cut and paste it from here): Public Sub GetPhoneBook() Dim strAddr As String strAddr = fstrGetAddressee() If strAddr <> "" Then System.PrivateProfileString("", EnvKey$ & "\" & _ EnvPhoneSubName$, EnvHookAddrKey$) = strAddr End If End Sub Private Function fstrGetAddressee() As String 'Copyright © 1998 Mike Craven. All rights reserved. 'Requires a project reference to: 'Microsoft CDO 1.2 Library (Collaboration Data Objects) Dim Answer As Integer Dim strZip As String Dim strCity As String Dim strState As String Dim strStreet As String Dim strSurName As String Dim strCountry As String Dim strGivenName As String Dim strMiddleName As String Dim strCompanyName As String Dim strHomeAddress As String Dim objSession As MAPI.Session Dim objRecipColl As Recipients Dim objAddrEntry As AddressEntry Dim strBusinessAddress As String On Error GoTo GetAddressee_Err Set objSession = CreateObject("MAPI.Session") objSession.Logon Set objRecipColl = objSession.AddressBook( _ Title:="Select Addressee", _ OneAddress:=True, _ ForceResolution:=True, _ RecipLists:=0) Set objAddrEntry = objRecipColl.Item(1).AddressEntry On Error Resume Next With objAddrEntry strGivenName = .Fields(CdoPR_GIVEN_NAME).Value strMiddleName = .Fields(CdoPR_MIDDLE_NAME).Value strSurName = .Fields(CdoPR_SURNAME).Value If strGivenName <> "" And strSurName <> "" Then strHomeAddress = _ strGivenName & _ IIf(strMiddleName <> "", _ " " & strMiddleName & " ", " ") & _ strSurName strStreet = .Fields(CdoPR_HOME_ADDRESS_STREET).Value strCity = .Fields(CdoPR_HOME_ADDRESS_CITY).Value strState = .Fields(CdoPR_HOME_ADDRESS_STATE_OR_PROVINCE).Value strZip = .Fields(CdoPR_HOME_ADDRESS_POSTAL_CODE).Value strCountry = .Fields(CdoPR_HOME_ADDRESS_COUNTRY).Value If strStreet <> "" And _ strCity <> "" And _ strState <> "" Then strHomeAddress = _ strHomeAddress & _ vbNewLine & strStreet & _ vbNewLine & strCity & ", " & strState & " " & strZip & _ IIf(strCountry <> "", vbNewLine & strCountry, "") End If End If strCompanyName = .Fields(CdoPR_COMPANY_NAME).Value If strCompanyName <> "" Then If strGivenName <> "" And strSurName <> "" Then strBusinessAddress = _ strGivenName & _ IIf(strMiddleName <> "", _ " " & strMiddleName & " ", " ") & _ strSurName & vbNewLine End If strBusinessAddress = strBusinessAddress & strCompanyName strStreet = .Fields(CdoPR_BUSINESS_ADDRESS_STREET).Value strCity = .Fields(CdoPR_BUSINESS_ADDRESS_CITY).Value strState = .Fields(CdoPR_BUSINESS_ADDRESS_STATE_OR_PROVINCE).Value strZip = .Fields(CdoPR_BUSINESS_ADDRESS_POSTAL_CODE).Value strCountry = .Fields(CdoPR_BUSINESS_ADDRESS_COUNTRY).Value If strStreet <> "" And _ strCity <> "" And _ strState <> "" Then strBusinessAddress = _ strBusinessAddress & _ vbNewLine & strStreet & _ vbNewLine & strCity & ", " & strState & " " & strZip & _ IIf(strCountry <> "", vbNewLine & strCountry, "") End If End If End With On Error GoTo 0 fstrGetAddressee = strHomeAddress If strBusinessAddress <> "" Then Answer = MsgBox( _ "Would you like to use the business " & _ "address for the selected contact?", _ vbQuestion + vbYesNo + vbDefaultButton2, _ "Get Addressee") If Answer = vbYes Then _ fstrGetAddressee = strBusinessAddress End If GetAddressee_End: On Error Resume Next objSession.Logoff On Error GoTo 0 Set objSession = Nothing Set objRecipColl = Nothing Set objAddrEntry = Nothing Exit Function GetAddressee_Err: If Err.Number <> CdoE_USER_CANCEL Then MsgBox _ "Error # " & Str(Err.Number) & " was generated by " _ & Err.Source & vbNewLine & vbNewLine & Err.Description, _ vbExclamation + vbMsgBoxHelpButton, "Get Addressee Error!", _ Err.HelpFile, Err.HelpContext End If Resume GetAddressee_End End Function 10. In the VBA Editor, select File/Save CustomEnvHooks. 11. In the VBA Editor, select File/Close and Return to Microsoft Word. 12. In Word, select File/Close to close the CustomEnvHooks.dot template. You should now have access to Outlook 98's addressbook from the AddressBook button in Enveloper's main dialog box.