Mike
asked on
Outlook Macro to Change Views
Hi - I need to write a macro in Outlook 2010 to toggle between two saved Views, as follows:
Assume the saved Views are called "View 1" and "View 2". To change from the current View to "View 1" manually I would type:
Click Tab 'View' > Click "Change View" > Click "View 1" from the list of saved views
I want a macro which has the following effect:
Case 1: If View 1 is current view the macro should change the view to View 2
Case 2: If View 2 is current view the macro should change the view to View 1
Case 3: if neither View 1 nor View 2 is the current view the macro should change the view to View 1
Can anyone assist with this?
Assume the saved Views are called "View 1" and "View 2". To change from the current View to "View 1" manually I would type:
Click Tab 'View' > Click "Change View" > Click "View 1" from the list of saved views
I want a macro which has the following effect:
Case 1: If View 1 is current view the macro should change the view to View 2
Case 2: If View 2 is current view the macro should change the view to View 1
Case 3: if neither View 1 nor View 2 is the current view the macro should change the view to View 1
Can anyone assist with this?
ASKER
Hi - unfortunately this does not seem to work. Running the macro has no visible effect.
Regards,
Mike
Regards,
Mike
Have you changed the View1 and View2 to your views?
ASKER
To test it I renamed the view names to View1 and View2 and simply pasted your text in.
Hi could you try this to see if the macros run
Sub Macro1()
Set objName = Application.GetNamespace("MAPI")
Set objviews = objName.GetDefaultFolder(olFolderInbox).Views
For Each vw In objviews
Debug.Print vw.Name
Next
End Sub
ASKER
nothing happens I'm afraid.
ASKER
Alexa I think perhaps you have posted an answer to a different question.
EDIT Could you try to exit from OL and re-enter to see if the macros run then
Which macro setting do you have?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks FarWest, much appreciated. Works like a charm.
Rgonzo1971 thanks for he;ping.
Rgonzo1971 thanks for he;ping.
pls try something like this
Open in new window
Regards