Excel - Calendar with weeknumber?

Asked By Stee on 13-Sep-07 04:22 PM
Hi
I am using the Calendar Control v11, and would like to know if it could be
possible to display the weeknumber in it as is the case in OutLook.
/Steen




Ron de Bruin replied on 13-Sep-07 04:47 PM
Hi Steen

Not that I know of

On this page I have a code example that you can use to add the week number (Excel or ISO) in a cell
http://www.rondebruin.nl/calendar.htm



--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
Rick Rothstein \(MVP - VB\) replied on 13-Sep-07 05:19 PM
If you use a MonthView control instead, it has a ShowWeekNumbers property
that can be set to True in order to display the week numbers.

Rick
Stee replied on 02-Oct-07 11:40 AM
Hi both of you two

I sorry that I first am back now - I havn't had time yet to test the two
suggestions, but I will do that in the weekend and come back.

/Stony
Stee replied on 02-Oct-07 04:08 PM
Hi Again

I have just taken a quick view at your suggestion, and I am not sure how to
find and use this MonthView control. I am not a skilled vba programmer, but
uses all the good information on your site among others.

Could you please ad a little more info on how to do?
Stee replied on 02-Oct-07 04:19 PM
Hi again

Thanks for your reply. I have been looking at your link, and it was a great
instruction in how to create and use the Calendar control.

But my question was actualy to have the week number on the Calendar control
as in Outlook - no action added to it.

Calendar control

Week | Month: xxxx, Year: yyyy
------------------------------------
12     | 01 02 03 04 05 06 07 |
13     | 08 09 10 11 12 13 14 |
14     | 15 16 17 18 19 20 21 |

Hope that you still are able to help :-)
Ron de Bruin replied on 02-Oct-07 04:41 PM
Sorry
There is no option for this in this control the way you want

--

Regards Ron de Bruin
http://www.rondebruin.nl/tips.htm
Rick Rothstein \(MVP - VB\) replied on 02-Oct-07 05:20 PM
Okay, it depends on where you are putting the MonthView control at....
directly on the spreadsheet or on a UserForm from within the VBA development
area.

From the spreadsheet
=====================
If you don't already have the Visual Basic toolbar showing, click...

View/Toolbars/Visual Basic

on Excel's menu bar. On the toolbar that displays, there is an icon that
looks like a hammer and wrench crossing each other... that is the Control
Toolbox... click it and then click the same looking icon on the panel that
displays (the ToolTip for it says "More Controls"). From the list box that
appears, select Microsoft MonthView Control 6 (at least, it shows 6 on my
system). That will place a MonthView control on the spreadsheet directly.
Right click the MonthView calendar that appears and click on Properties in
the popup menu that appears. Set the ShowWeekNumbers property to True to
show the week numbers on the calendar. You might have to change the
TitleBackColor property in order to make the numbers easier to see
(depending on the theme setting for your copy of Windows). You can use the
LinkedCell property to specify the cell you want to show the selected date.

On a UserControl
====================
Right click the Sheet1 tab at the bottom of the sheet and select View Code
from the popup menu (or press Alt+F11) to get into the VBA editor. You can
add a UserForm to your project by clicking Insert/UserForm from the VBA
editor's menu bar. Right click anywhere on the Toolbox panel that comes up
with the UserForm when you add it. Find Microsoft MonthView Control 6 on the
list that appears and check it off. This will put the MonthView icon into
the Toolbox... find the icon, click it and then drag-draw the control into
the Userform. If the Properties window is not showing, right click the
calendar and select Properties from the popup menu. Set the ShowWeekNumbers
property to True to show the week numbers on the calendar. You might have to
change the TitleBackColor property in order to make the numbers easier to
see (depending on the theme setting for your copy of Windows).

Okay, that makes the MonthView control available. What you do next depends
on how you want to interact with the user and what you know about how to do
that. It is a little hard to guide you further at this point.

Rick
Stee replied on 03-Oct-07 02:20 PM
Hi Rick

That's just great - just what I wanted :-)

I am using it in a userform almost in the way describe in

http://www.rondebruin.nl/calendar.htm

Will the code work for this control too?
Stee replied on 03-Oct-07 02:23 PM
Hi again Rick

Just a little correction - this is the code I am using for the Calendar
control:
http://www.fontstuff.com/vba/vbatut07.htm
Rick Rothstein \(MVP - VB\) replied on 03-Oct-07 03:04 PM
I took a quick look at the link you provided. I believe you can follow all
directions shown and you can use the MonthView control in place of the
Calendar control shown there; HOWEVER, you need to make these minor
modification in order for everything to work. First, after placing the
MonthView control on the form, rename it to Calendar1; that way, you can use
the code exactly as written. Second, the MonthView control does not have a
Click event; rather, it has a DateClick event. So, you will have to change
this procedure header used in the code from the link you provided...

Private Sub Calendar1_Click()

to this instead...

Private Sub Calendar1_DateClick(ByVal DateClicked As Date)

Making the two indicated changes above should (remember, I didn't test it)
allow you to use the rest of the code/implementation exactly as described in
the text at that link. Just so you know, the size of the MonthView control
is set by the size of the font, not by dragging the sizing handles. So, to
resize it, use the Font property from the Properties window.

Rick
Stee replied on 03-Oct-07 03:26 PM
Hi again Rick

Thanks for the quick answer - I will try i tomorrow an let you know how it
went :-)

/Stony
Stee replied on 05-Oct-07 10:41 AM
Hi again Rick

Thanks - it works nice.

But I have got a small problem - I can't call it from another module/sheet
with:

Call OpenCalendar

Is that because it's defined in the Prival.xls
Mark Davis replied to Rick Rothstein \(MVP - VB\) on 23-Mar-10 02:35 PM
I use the week number, as you have outlined, in Outlook 2007.  I just noticed that it is off a week this year, due to 53 weeks last year.  When I check the ISO convention, MS has definitely programming wrong:  this week, which is KW 13 in Outlook, should be KW12 ISO.

Howdo we fix this?