![]() |
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
|
|||
|
|||
![]()
All, I'm trying to use the code below as explained on this page:
http://msdn.microsoft.com/library/de...11olevents.asp However, the code runs and it works fine when Outlook first runs but it does not changes my view when I switch folders. Any thoughts? 'ThisOutlookSession code Private Sub Application_Startup() Dim m_explevents As New ExplEvents m_objExplorer_FolderSwitch End Sub Listing 11.7 Enforcing a Default Folder View 'ExplEvents class module Private WithEvents m_colExplorers As Outlook.Explorers Private WithEvents m_objExplorer As Outlook.Explorer Sub Class_Terminate() Call DeRefExplorers End Sub Public Sub InitExplorers(objApp As Outlook.Application) Set m_colExplorers = objApp.Explorers If m_colExplorers.Count 0 Then Set m_objExplorer = objApp.ActiveExplorer End If End Sub Public Sub DeRefExplorers() Set m_colExplorers = Nothing Set m_objExplorer = Nothing End Sub Private Sub Application_Startup() Dim m_explevents As New ExplEvents m_explevents.InitExplorers Application m_explevents.m_objExplorer_FolderSwitch End Sub Public Sub m_objExplorer_FolderSwitch() Set myOlApp = CreateObject("Outlook.Application") Dim olns As Outlook.NameSpace Set olns = myOlApp.GetNamespace("MAPI") Dim SearchFolder As Outlook.MAPIFolder Dim myOlExp As Outlook.Explorer Dim vw As Outlook.View Set myOlExp = myOlApp.ActiveExplorer Set SearchFolder = myOlExp.CurrentFolder myType = SearchFolder.DefaultItemType Set vw = SearchFolder.CurrentView If myType = 0 Then MsgBox myType 'Set current view to "By Company" If Not vw.Name = "MyView" Then myOlExp.CurrentView = "MyView" End If End If Set myOlApp = Nothing Set olns = Nothing Set SearchFolder = Nothing Set myOlExp = Nothing Set vw = Nothing Set myType = Nothing End Sub |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Outlook 2003 "find" contacts doesn't work, just runs and runs | Tom Stanley | Outlook - Using Contacts | 1 | July 5th 06 03:56 AM |
ThisOutlookSession not starting | Wanda | Outlook and VBA | 2 | June 9th 06 07:48 PM |
Vba Project OTM - Thisoutlooksession(code) error | XP User | Outlook and VBA | 4 | May 7th 06 03:31 PM |
Code runs in design mode | karlman | Outlook - Using Forms | 2 | January 27th 06 05:49 PM |
My program runs very slow | קובץ | Outlook and VBA | 6 | January 22nd 06 03:46 PM |