![]() |
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 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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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:
|
#8
|
|||
|
|||
![]()
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
|
|||
|
|||
![]()
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:
|
#10
|
|||
|
|||
![]()
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 |
Display Modes | |
|
|
![]() |
||||
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 |