Active X CAlender day colour

J

Joel

Dear All,

This maybe a very simple question but I have created a calender in excel
using active X I was wondering how I would go about colouring in for example
every Wednesday of that month so they stand out I have looked in all the
properties and I haven't found a way

Kind regards Joel
 
L

Leith Ross

Dear All,

This maybe a very simple question but I have created a calender in excel
using active X I was wondering how I would go about colouring in for example
every Wednesday of that month so they stand out I have looked in all the
properties and I haven't found a way

Kind regards Joel

Hello Joel,

If you are referring to a MonthView control, you can bold the days you
want. Since this control has a window handle, it might be possible to
use the API to color the selected dates, but I not sure it would be
worth the effort to make the dates stand out.

Here are the code routines to bold the Wednesdays month by month. The
MonthView is on a UserForm.
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Sub BoldWednesdays()

Dim D As Variant
Dim FirstDay As Long
Dim LastDay As Long
Dim M As Long, y As Long

With MonthView1
y = .Year
M = .Month
End With

FirstDay = DateSerial(y, M, 1)
LastDay = DateSerial(y, M + 1, 1) - 1

DoEvents

For D = FirstDay To LastDay
If Weekday(D, vbSunday) = 4 Then
MonthView1.DayBold(D) = True
End If
Next D

End Sub

Private Sub MonthView1_MouseMove(ByVal Button As Integer, ByVal Shift
As Integer, ByVal x As stdole.OLE_XPOS_PIXELS, ByVal y As
stdole.OLE_YPOS_PIXELS)

Dim Ret

Ret = MonthView1.HitTest(x, y, MonthView1.Value)
Select Case Ret
Case Is = 8, 9
BoldWednesdays
End Select

End Sub

Private Sub UserForm_Activate()

BoldWednesdays

End Sub
 
J

Joel

Hi thanks for the code, I have tried and can't seem to get it work. I am
double clicking the calender and pasting the code in to there. Please can you
help

Thanks Joel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top