S
Simon Minder
Hi all,
I have a problem with my template in 2007. I worte a template in 2003 with
VBA code behind. Everything works fine there, however, if I run this in 2007
the program stops at 'Set olApp = CreateObject("Outlook.Application")' (see
the whole code below). Are there any changes in VBA between 2003 and 2007? Or
why can I not create such an object?
Private Sub cmdSearchContact_Click()
Dim olApp As Outlook.Application
Dim objContact As Outlook.ContactItem
Dim objContacts As Outlook.MAPIFolder
Dim objNameSpace As Outlook.NameSpace
Dim objAllContacts As Object
' Reset List
lstContacts.Clear
Set olApp = CreateObject("Outlook.Application")
Set objNameSpace = olApp.GetNamespace("MAPI")
If optPersonalContacts = True Then
Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts)
ElseIf optMfoContacts = True Then
Set objContacts = objNameSpace.Folders("Public Folders"). _
Folders("All Public Folders"). _
Folders("MFO Contacts")
End If
Set objAllContacts = objContacts.Items
For Each objContact In objAllContacts
If objContact.FullName Like "*" & txtSearchContact & "*" Then
lstContacts.AddItem objContact.FullName
Else
' Do nothing
End If
Next
End Sub
Kind regards,
Simon Minder
I have a problem with my template in 2007. I worte a template in 2003 with
VBA code behind. Everything works fine there, however, if I run this in 2007
the program stops at 'Set olApp = CreateObject("Outlook.Application")' (see
the whole code below). Are there any changes in VBA between 2003 and 2007? Or
why can I not create such an object?
Private Sub cmdSearchContact_Click()
Dim olApp As Outlook.Application
Dim objContact As Outlook.ContactItem
Dim objContacts As Outlook.MAPIFolder
Dim objNameSpace As Outlook.NameSpace
Dim objAllContacts As Object
' Reset List
lstContacts.Clear
Set olApp = CreateObject("Outlook.Application")
Set objNameSpace = olApp.GetNamespace("MAPI")
If optPersonalContacts = True Then
Set objContacts = objNameSpace.GetDefaultFolder(olFolderContacts)
ElseIf optMfoContacts = True Then
Set objContacts = objNameSpace.Folders("Public Folders"). _
Folders("All Public Folders"). _
Folders("MFO Contacts")
End If
Set objAllContacts = objContacts.Items
For Each objContact In objAllContacts
If objContact.FullName Like "*" & txtSearchContact & "*" Then
lstContacts.AddItem objContact.FullName
Else
' Do nothing
End If
Next
End Sub
Kind regards,
Simon Minder