![]() |
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, I want to add the VBA code mentioned in the first part of this link to my Outlook 2003: http://www.outlookcode.com/article.aspx?id=72 The problem that I am running into is that I already have some code in my ThisOutlookSession that I would like to keep and if I just plop this code in before the other code, this new code doesn't work. If I drop the code mentioned in the link above into an empty ThisOutlookSession on another machine, it works fine. I am probably missing some simple step, but do very little with VBA in Outlook and have been unable to find what I am looking for by Googling. Here is the code that I already have in place. I believe it does something with the setup of my Outlook Contacts. Again, my goal is to have the code below continue to work plus the code in the first part of the link above: Public Sub ChangeFileAs() Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim objContact As Outlook.ContactItem Dim objItems As Outlook.Items Dim objContactsFolder As Outlook.MAPIFolder Dim obj As Object Dim strFirstName As String Dim strLastName As String Dim strCompanyName As String Dim strFileAs As String On Error Resume Next Set objOL = CreateObject("Outlook.Application") Set objNS = objOL.GetNamespace("MAPI") Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts) Set objItems = objContactsFolder.Items For Each obj In objItems 'Test for contact and not distribution list If obj.Class = olContact Then Set objContact = obj With objContact strFirstName = .FirstName strLastName = .LastName strCompanyName = .CompanyName strFileAs = strCompanyName & " " & "(" & strLastName & ", " & strFirstName & ")" .FileAs = strFileAs .Save End With End If Err.Clear Next Set objOL = Nothing Set objNS = Nothing Set obj = Nothing Set objContact = Nothing Set objItems = Nothing Set objContactsFolder = Nothing End Sub Any help would be appreciate. Thanks, -- NatDev http://forums.slipstick.com |
Ads |
#2
|
|||
|
|||
![]()
There's no reason at all why if you used method 1 at your link that it would
interfere with your running that macro to re-order your contact filing. Both pieces of code can co-exist. -- Ken Slovak [MVP - Outlook] http://www.slovaktech.com Author: Professional Programming Outlook 2007. Reminder Manager, Extended Reminders, Attachment Options. http://www.slovaktech.com/products.htm "NatDev" NatDev.4aliny@invalid wrote in message news:NatDev.4aliny@invalid... Hi, I want to add the VBA code mentioned in the first part of this link to my Outlook 2003: http://www.outlookcode.com/article.aspx?id=72 The problem that I am running into is that I already have some code in my ThisOutlookSession that I would like to keep and if I just plop this code in before the other code, this new code doesn't work. If I drop the code mentioned in the link above into an empty ThisOutlookSession on another machine, it works fine. I am probably missing some simple step, but do very little with VBA in Outlook and have been unable to find what I am looking for by Googling. Here is the code that I already have in place. I believe it does something with the setup of my Outlook Contacts. Again, my goal is to have the code below continue to work plus the code in the first part of the link above: Public Sub ChangeFileAs() Dim objOL As Outlook.Application Dim objNS As Outlook.NameSpace Dim objContact As Outlook.ContactItem Dim objItems As Outlook.Items Dim objContactsFolder As Outlook.MAPIFolder Dim obj As Object Dim strFirstName As String Dim strLastName As String Dim strCompanyName As String Dim strFileAs As String On Error Resume Next Set objOL = CreateObject("Outlook.Application") Set objNS = objOL.GetNamespace("MAPI") Set objContactsFolder = objNS.GetDefaultFolder(olFolderContacts) Set objItems = objContactsFolder.Items For Each obj In objItems 'Test for contact and not distribution list If obj.Class = olContact Then Set objContact = obj With objContact strFirstName = .FirstName strLastName = .LastName strCompanyName = .CompanyName strFileAs = strCompanyName & " " & "(" & strLastName & ", " & strFirstName & ")" FileAs = strFileAs Save End With End If Err.Clear Next Set objOL = Nothing Set objNS = Nothing Set obj = Nothing Set objContact = Nothing Set objItems = Nothing Set objContactsFolder = Nothing End Sub Any help would be appreciate. Thanks, -- NatDev http://forums.slipstick.com |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Custom Archive code -- modify my code! | Ray[_5_] | Outlook and VBA | 3 | November 17th 09 10:16 PM |
Using VBA code in ThisOutlookSession - Can I send an email asynchronously? | Steve[_3_] | Outlook and VBA | 3 | August 31st 07 07:41 AM |
Outlook 2007 - Code in ThisOutlookSession Stops Working | [email protected] | Outlook and VBA | 8 | August 9th 07 08:02 PM |
ThisOutlookSession - code runs only once | Rafael1119 | Outlook and VBA | 8 | July 17th 06 12:51 PM |
Vba Project OTM - Thisoutlooksession(code) error | XP User | Outlook and VBA | 4 | May 7th 06 04:31 PM |