View Single Post
  #4   Report Post  
Posted to microsoft.public.excel.misc
JLatham JLatham is offline
external usenet poster
 
Posts: 3,365
Default Calendar code not working

RobN,
First - NO! don't overwrite either copy of your mscal.ocx control on either
machine. If we get into messing with copying them from one to the other, use
the rename trick to temporarily take one of them out of the picture. We want
to be able to bring both systems back to their current state even if we don't
succeed in getting things working at the office. Let's hold off on trying
anything like that for the moment - I don't want to tell you to do something
that may make things worse.

#1. To be able to right click on the calendar control and see its
properties, you need to be in design mode. Open up the Controls Toolbox and
you'll see the little Triangle, Ruler and Pencil icon at the upper left.
That takes you in and out of design mode.

#2. I think we need to find out why you cannot Insert Object in 2007. To
insert one into a new book in Excel 2007, you are generally correct:
Developer Tab - Insert | More Controls and select the Calendar 12 control
and click [OK] then your cursor should change to a very thin + mark and
basically you click and drag to create a rectangle on the sheet that is about
the size you want for the calendar. When you release the mouse button the
calendar control should appear and you should be able to resize it. That's
the way it's supposed to work - or at least the way it worked for me here.

#3 - in theory, since there is a copy of mscal.ocx on the machine at the
office, you should NOT have to place an older copy (from home system) onto
that machine. The copy on the office machine should be a later version and
it should be backward compatible with earlier version of the calendar control.

I'm thinking (could be wrong) that the these two issues are related: that
the workbook with calendar from home that works doesn't work at the office,
and that you aren't permitted to insert a calendar control into a brand new
workbook on the system at the office in 2007. Problem is, I honestly don't
know where to begin to look for the answer to that riddle right now. Going
to have to ask around and do some research. I'll start that process now. If
you don't hear back shortly, it's not that I've abandonded you, it's just
that I don't have an answer yet.


"RobN" wrote:

Thankyou for your reply.

1. I can't right click on the control as it doesn't ever appear (I just get
the message saying "Object required".) When I right click on the previous
version's control, where it does work, nothing happens. ie no menu allowing
me to select properties.

2. How do I delete the existing (supposedly faulty) Calendar control? I'm
not even sure how to go about creating a new control in 2007. Do I select
(in the Developer Tab) Insert, then the CalsControl Control option from the
More Controls option. When I try that I get a message (even on a blank new
workbook) that I cannot Insert Object!

3. I do have the mscal.ocx file on my office computer. Should I really
replace that with the XP versions mscal.ocx file from my home computer? Or
should I rename, etc.

I'm sorry, but even though I created the Calendar Control in XP, I don't
really understand what's happening, particularly now that 2007 is so much
different.

Rob

"JLatham" <HelpFrom @ Jlathamsite.com.(removethis) wrote in message
...
My first thought is that your Calendar control may have changed names
during
the copy. Right click the calendar control and choose Properties and see
what the control's name is. If other than Calendar3, then change code to
get
it to work. If you can't see it or get to it for this, read on...

But since it works at home, and not at work - it could be a library
problem.
You may have a calendar that is created with XP version of the calendar
control and it may not exist on your office computer. You may need to
simply delete the calendar in the office file copy and create a new one
based
on the calendar control available on that computer.

Another option is to make a copy of the mscal.ocx file on your home
machine
and make it available on your office system. On my system, the file is
located at c:\Program Files\Microsoft Office\OFFICE11\MSCAL.OCX

"RobN" wrote:

I have the following code to bring up the Calendar control. When I
converted the excel workbook from XP version to 2007 version on my home
computer it worked fine, but when I open it on my office computer I get a
message saying "Object required". When I open the older version on my
office computer, the Calendar code works OK.
Can you please also advise what code I need to control the size of the
Calendar?

Rob

Private Sub Worksheet_SelectionChange(ByVal Target As Range)
If Target.Cells.Count 1 Then Exit Sub
If Not Application.Intersect(Range("H2"), Target) Is Nothing Then
Calendar3.Left = Target.Left + Target.Width * 2 - Calendar3.Width
Calendar3.Top = Target.Top + Target.Height * 7.5
Calendar3.Visible = True
' select Today's date in the Calendar
Calendar3.Value = Date
ElseIf Calendar3.Visible Then Calendar3.Visible = False
End If
End Sub