C
Cole
Hi folks,
I've got code in Excel to see if there's an instance of Outlook
running. Problem is, whether it is running or not already, the last
command where I'm trying to change focus to Outlook Contacts creates a
new instance of Outlook Contacts. Any suggestions on what I'm missing?
Greatly appreciated!
-Cole - Here my code thus far:
' This is button to change focus to Outlook Contacts:
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")
' Next line does set objFolder to "Contacts"
Set objFolder = objnamespace.GetDefaultFolder(olFolderContacts)
' Then this next line is what opens a new instance of Outlook, even if
Contacts are already open.
objFolder.Display
I've got code in Excel to see if there's an instance of Outlook
running. Problem is, whether it is running or not already, the last
command where I'm trying to change focus to Outlook Contacts creates a
new instance of Outlook Contacts. Any suggestions on what I'm missing?
Greatly appreciated!
-Cole - Here my code thus far:
' This is button to change focus to Outlook Contacts:
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")
' Next line does set objFolder to "Contacts"
Set objFolder = objnamespace.GetDefaultFolder(olFolderContacts)
' Then this next line is what opens a new instance of Outlook, even if
Contacts are already open.
objFolder.Display