![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
![]()
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 |
#2
|
|||
|
|||
![]()
There were no changes to VBA that would cause CreateObject not to work.
Possibilities are a security setting in Word not allowing code to run or some script stopper in an A-V or software firewall preventing CreateObject from working. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003 Reminder Manager, Extended Reminders, Attachment Options http://www.slovaktech.com/products.htm "Simon Minder" wrote in message news ![]() 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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
How to access a custom control in an outlook form from my VBA code? | MeAgin | Outlook and VBA | 1 | January 23rd 07 05:39 AM |
VBA code not starting on some Outlook 2003 clients, does on others. | [email protected] | Outlook and VBA | 3 | May 17th 06 05:21 PM |
VBA Code to put in Access that will send an Email with Attachments | [email protected] | Outlook and VBA | 1 | April 9th 06 05:30 PM |
Using VBA for Outlook and VBA for Access within Access | Sardonic | Outlook and VBA | 1 | March 17th 06 12:34 PM |
Running query from Access Form commmand using VBA code | Berny | Outlook and VBA | 4 | January 16th 06 02:12 PM |