A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Changing calendar views



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 26th 09, 02:37 PM
Douglas Quaid Douglas Quaid is offline
Junior Member
 
First recorded activity at Outlookbanter: Jun 2009
Posts: 7
Question Changing calendar views

Hi, I am new to Outlook and just getting my feet wet on the VB commands for it, so I thought I would start with something simple but even this little task is eluding me. I prefer to have my calendar view set to "one day" for today, but all day long I need to set appointments one month out, and I like to view the calendar one month out in Work Week view. I would like to create one button I can click that will automatically shift the view four weeks into the future and switch the view to "Work Week," and another button that will take me back to today and switch the view to "one day."

Also, I would like to make a button that shifts the view forward one week, and another that shifts the view backwards one week. I would put all these buttons on a custom toolbar so I could navigate around the calendar easily.

Any help would be greatly appreciated.
Ads
  #2  
Old June 29th 09, 03:24 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Changing calendar views

Outlook version?

--
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


"Douglas Quaid" wrote in message
news

Hi, I am new to Outlook and just getting my feet wet on the VB commands
for it, so I thought I would start with something simple but even this
little task is eluding me. I prefer to have my calendar view set to
"one day" for today, but all day long I need to set appointments one
month out, and I like to view the calendar one month out in Work Week
view. I would like to create one button I can click that will
automatically shift the view four weeks into the future and switch the
view to "Work Week," and another button that will take me back to today
and switch the view to "one day."

Also, I would like to make a button that shifts the view forward one
week, and another that shifts the view backwards one week. I would put
all these buttons on a custom toolbar so I could navigate around the
calendar easily.

Any help would be greatly appreciated.




--
Douglas Quaid


  #3  
Old June 30th 09, 01:21 PM
Douglas Quaid Douglas Quaid is offline
Junior Member
 
First recorded activity at Outlookbanter: Jun 2009
Posts: 7
Default

Outlook 2003 SP3
Quote:
Originally Posted by Ken Slovak - [MVP - Outlook] View Post
Outlook version?

--
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


"Douglas Quaid" wrote in message
news

Hi, I am new to Outlook and just getting my feet wet on the VB commands
for it, so I thought I would start with something simple but even this
little task is eluding me. I prefer to have my calendar view set to
"one day" for today, but all day long I need to set appointments one
month out, and I like to view the calendar one month out in Work Week
view. I would like to create one button I can click that will
automatically shift the view four weeks into the future and switch the
view to "Work Week," and another button that will take me back to today
and switch the view to "one day."

Also, I would like to make a button that shifts the view forward one
week, and another that shifts the view backwards one week. I would put
all these buttons on a custom toolbar so I could navigate around the
calendar easily.

Any help would be greatly appreciated.




--
Douglas Quaid
  #4  
Old July 1st 09, 01:11 AM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Changing calendar views

To add any macro to a toolbar as a button select View, Toolbars, Customize.
Select the macro from the Commands list and drag it to the toolbar. A macro
is a Public Sub in an Outlook code module or in ThisOutlookSession.

I'll leave it to you to make the other macros for different time periods,
and also to add error handling and checking for things like each object not
being Nothing. Here's a macro that will move 4 weeks in the future. Note
that Work Week is from a button click, not directly from setting a specific
view.

Sub ViewChange()
Dim exp As Outlook.Explorer
Dim folder As Outlook.MAPIFolder
Dim button As Office.CommandBarButton

Dim dat As Date

Set exp = Application.ActiveExplorer

Set folder = exp.CurrentFolder

' set view
exp.CurrentView = "Day/Week/Month"

' set Work Week "view"
Set button = exp.CommandBars.Item("Standard").FindControl(id:=5 556,
Recursive:=True)
button.Execute

' go to 4 weeks from now
dat = DateAdd("d", 28, Date)
exp.CurrentView.GoToDate dat

Set exp = Nothing
Set folder = Nothing
Set button = Nothing
End Sub

--
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


"Douglas Quaid" wrote in message
news

Outlook 2003 SP3
'Ken Slovak - [MVP - Outlook Wrote:
;312287']Outlook version?

--
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


"Douglas Quaid" wrote in
message
news
Hi, I am new to Outlook and just getting my feet wet on the VB
commands
for it, so I thought I would start with something simple but even
this
little task is eluding me. I prefer to have my calendar view set to
"one day" for today, but all day long I need to set appointments one
month out, and I like to view the calendar one month out in Work Week
view. I would like to create one button I can click that will
automatically shift the view four weeks into the future and switch
the
view to "Work Week," and another button that will take me back to
today
and switch the view to "one day."

Also, I would like to make a button that shifts the view forward one
week, and another that shifts the view backwards one week. I would
put
all these buttons on a custom toolbar so I could navigate around the
calendar easily.

Any help would be greatly appreciated.




--
Douglas Quaid -





--
Douglas Quaid


  #5  
Old July 1st 09, 03:46 PM
Douglas Quaid Douglas Quaid is offline
Junior Member
 
First recorded activity at Outlookbanter: Jun 2009
Posts: 7
Smile

Thanks, Ken, this is good stuff. The one thing that worked a little better for me was replacing "Date" with "Now" in the DateAdd code. With "Date" it was going to 12 AM and then I would have to scroll down. With "Now" it goes to the current time, which is perfect for me.

The only problem I still have is jumping forward or backward a week from the currently selected date, as opposed to today's date. If you could point me in the right direction for that I would really appreciate it.
  #6  
Old July 1st 09, 07:05 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Changing calendar views

The key is the DateAdd() function. Change 28 days to 7 and you jump a week.
Change it to -28 and you jump back 4 weeks from today. Make a new macro for
each different date jump you want and name them appropriately.

For more on DateAdd() use the help.

--
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


"Douglas Quaid" wrote in message
news

Thanks, Ken, this is good stuff. The one thing that worked a little
better for me was replacing "Date" with "Now" in the DateAdd code.
With "Date" it was going to 12 AM and then I would have to scroll down.
With "Now" it goes to the current time, which is perfect for me.

The only problem I still have is jumping forward or backward a week
from the currently selected date, as opposed to today's date. If you
could point me in the right direction for that I would really
appreciate it.




--
Douglas Quaid


  #7  
Old July 2nd 09, 04:06 PM
Douglas Quaid Douglas Quaid is offline
Junior Member
 
First recorded activity at Outlookbanter: Jun 2009
Posts: 7
Default

Ken, I really appreciate your time. I don't think I explained what I am trying to do well enough. I understand the DateAdd() function. What I need to do, though, is to jump a week forward or back from the Currently Selected Date. Not a week forward or back from Today. Does that make sense?

The DateAdd() help only tells you how to jump from today, or from a specific date. I need a command to return a string with whatever date I'm currently looking at to fill in that last variable in the DateAdd function.

Quote:
Originally Posted by Ken Slovak - [MVP - Outlook] View Post
The key is the DateAdd() function. Change 28 days to 7 and you jump a week.
Change it to -28 and you jump back 4 weeks from today. Make a new macro for
each different date jump you want and name them appropriately.

For more on DateAdd() use the help.

--
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

  #8  
Old July 3rd 09, 03:10 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Changing calendar views

No way to do that in Outlook 2003. That's not exposed to the object model.

In Outlook 2007 you could use the new CalendarView.DisplayedDates property
to let you know which dates were currently visible in the UI.

--
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


"Douglas Quaid" wrote in message
news

Ken, I really appreciate your time. I don't think I explained what I am
trying to do well enough. I understand the DateAdd() function. What I
need to do, though, is to jump a week forward or back from the
Currently Selected Date. Not a week forward or back from Today. Does
that make sense?

The DateAdd() help only tells you how to jump from today, or from a
specific date. I need a command to return a string with whatever date
I'm currently looking at to fill in that last variable in the DateAdd
function.


  #9  
Old July 7th 09, 10:08 PM
Douglas Quaid Douglas Quaid is offline
Junior Member
 
First recorded activity at Outlookbanter: Jun 2009
Posts: 7
Default

OK, thanks for your help Ken. One last thing- is there a list of all the button IDs somewhere online (for example, Work Week View is 5556)?


Quote:
Originally Posted by Ken Slovak - [MVP - Outlook] View Post
No way to do that in Outlook 2003. That's not exposed to the object model.

In Outlook 2007 you could use the new CalendarView.DisplayedDates property
to let you know which dates were currently visible in the UI.

--
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


"Douglas Quaid" wrote in message
news

Ken, I really appreciate your time. I don't think I explained what I am
trying to do well enough. I understand the DateAdd() function. What I
need to do, though, is to jump a week forward or back from the
Currently Selected Date. Not a week forward or back from Today. Does
that make sense?

The DateAdd() help only tells you how to jump from today, or from a
specific date. I need a command to return a string with whatever date
I'm currently looking at to fill in that last variable in the DateAdd
function.
  #10  
Old July 8th 09, 03:02 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Changing calendar views

There are some at various places at www.outlookcode.com, but it's nothing
like a comprehensive list.

What I usually do is use OutlookSpy (www.dimastr.com) for that. I also use
it to get property tags for various MAPI properties. Anyway, that's how I
got the ID for that button for you. With OutlookSpy you select the Explorer
or Inspector button as appropriate and in the window that opens there's a
CommandBars tab. In that you select the relevant toolbar/menu and you'll see
a list of every button in that toolbar/menu.

For ribbon controls you set up to customize the QAT and each control's idMso
is then listed when you hover over the command. The idMso's are also listed
in the downloads for the ribbon schemas from Office Online.

--
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


"Douglas Quaid" wrote in message
news

OK, thanks for your help Ken. One last thing- is there a list of all
the button IDs somewhere online (for example, Work Week View is 5556)?


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Changing calendar views snaps to current date hominah Outlook - Calandaring 2 September 11th 08 07:59 PM
Changing views nojo901 Outlook - Calandaring 2 March 6th 08 09:39 PM
Changing Outlook calendar views anon Outlook - Calandaring 2 June 1st 06 07:19 PM
changing column views in folders MG Outlook Express 1 April 24th 06 04:26 PM
Changing Views in Calendar Always Reverts Back to Today's Date Matt Outlook - General Queries 0 February 10th 06 09:01 PM


All times are GMT +1. The time now is 04:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.