Programmactically add calendar control to userform

G

Guest

Hi all,

I'm trying to write a patch for a program of mine. The program uses Calendar
Control 9.0 and is installed on a network drive. A copy of MSCal.OCX has been
added to the same folder. The program is intended to be used by several
people in the office.

Unfortunately, apparently many don't have the calendar control file and/or
don't have it registered. This causes an error message and causes the
calendar control to disappear from the userform when the program is opened. I
have successfully fixed the problem manually for one computer but it is
impractical to do this for the entire office. It is uncertain how many and
whom will end up using it.

I'm hoping I can write a patch that will check for the calendar control and,
if not found, register the file (on the network drive) and programmatically
add it to the userform. I know how to use the Shell command to automatically
run Regsvr32 and register the calendar control. I also know how to
programmatically add a reference to the VBA Extensibility Library. However,
I've been unsuccessful at programmatically adding the control to the userform.

Hoping someone can help or suggest a better solution.

Best regards,
Greg
 
G

Guest

I finally got it to work. I'm still interested in any better solutions than
the patch idea. This worked:

With Application.VBE.ActiveVBProject.VBComponents("Userform1").Designer
.Controls.Add("MSCal.Calendar.7")
End With

Regards,
Greg
 
R

RB Smissaert

I had a similar problem and solved it by ditching MSCal.ocx and use the
MonthView control. This is part of the Windows Common Controls and is always
present. It has the same or better features.

RBS
 
G

Guest

Thanks for responding. That sounds like the ticket. I'll check it out.

Best regards,
Greg
 
D

David

RB Smissaert wrote
I had a similar problem and solved it by ditching MSCal.ocx and use
the MonthView control. This is part of the Windows Common Controls and
is always present. It has the same or better features.

Where would that control be found?
 
R

RB Smissaert

It is part of MSCOMCT2.OCX
The control is called Microsoft MonthView Control.
I have version 6.0

RBS
 
D

David

RB Smissaert wrote
It is part of MSCOMCT2.OCX
The control is called Microsoft MonthView Control.
I have version 6.0

RBS

Thanks. I guess since this is an Excel programming group, my next question
would be 'How do I make use of it in Excel?'
 
R

RB Smissaert

Make a userform, add the control to the available controls,
put it on the userform and add the code.
The code will be very similar as that used with MSCal.ocx

RBS
 
D

David

RB Smissaert wrote
Make a userform, add the control to the available controls,
put it on the userform and add the code.
The code will be very similar as that used with MSCal.ocx

RBS

Thanks.
 

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