C
Cole
I'm trying to give the user a button to push in a spreadsheet to simply
change focus to Outlook Contacts. Everything seems to work except the
very last command - the one to change focus. What am I missing?
Here's what I've got so far:
Dim ObjOutlook As Outlook.Application
Dim bWasntRunning As Boolean
bWasntRunning = False
On Error Resume Next
' Try first to use an existing instance.
Set ObjOutlook = GetObject(, "Outlook.Application")
If Err Then ' Outlook isn't running, so start it.
bWasntRunning = True
Set ObjOutlook = CreateObject("Outlook.Application")
End If
Set objnamespace = ObjOutlook.GetNamespace("MAPI")
Set objFolder = objnamespace.GetDefaultFolder(olFolderContacts) ' This
stmt does set objFolder to "Contacts"
objFolder.Display 'This creates a new instance of Outlook
'regardless of whether one is already
'open or not. Take this out, and I get no
'change of focus to Outlook Contacts.
Any help would be greatly appreciated. Thanks!
change focus to Outlook Contacts. Everything seems to work except the
very last command - the one to change focus. What am I missing?
Here's what I've got so far:
Dim ObjOutlook As Outlook.Application
Dim bWasntRunning As Boolean
bWasntRunning = False
On Error Resume Next
' Try first to use an existing instance.
Set ObjOutlook = GetObject(, "Outlook.Application")
If Err Then ' Outlook isn't running, so start it.
bWasntRunning = True
Set ObjOutlook = CreateObject("Outlook.Application")
End If
Set objnamespace = ObjOutlook.GetNamespace("MAPI")
Set objFolder = objnamespace.GetDefaultFolder(olFolderContacts) ' This
stmt does set objFolder to "Contacts"
objFolder.Display 'This creates a new instance of Outlook
'regardless of whether one is already
'open or not. Take this out, and I get no
'change of focus to Outlook Contacts.
Any help would be greatly appreciated. Thanks!