Share this Page URL

The Document Object > The Document Object - Pg. 429

a contact item currently open in Outlook, writing the name and address data to the new blank letter. Note that this procedure hands back an error if Outlook is not open, or a contact is not open in Outlook. Example 18-34. Running a Procedure when Creating a New Document Private Sub Document_New( On Error GoTo ErrorHandler Dim appOutlook As Outlook.Application Dim ins As Outlook.Inspector 'Dim exp As Outlook.Explorer Dim nms As Outlook.NameSpace Dim itm As Object Dim strFullName As String Dim strAddress As String Dim strSalutation As String Dim strDocName As String 'Set reference to Outlook item Set appOutlook = CreateObject("Outlook.Application") Set nms = appOutlook.GetNamespace("MAPI") Set ins = appOutlook.ActiveInspector 'Set exp = appOutlook.ActiveExplorer Set itm = ins.CurrentItem If itm.Class <> olcontact Then )