Solved

MS Excel 2003, programmatically add calendar control to form using VBA

Posted on 2006-07-24
5
595 Views
Last Modified: 2008-01-09
I am trying to add a Calendar Control (MSACAL) to a form using VBA  using the following:
Dim calControl As Control
Set calControl = fSetup.Controls _
    .Add("MSACAL.Calander.1", "calControl", True)

When this code runs, I receive a runtime error stating “invalid class string”:

I do have a reference to the msacal.ocx established.  Apparently, I am referencing the ProgID incorrectly.
0
Comment
Question by:ArtBarnwell
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
5 Comments
 
LVL 7

Expert Comment

by:yotamsher
ID: 17169594
I think you have a typo

it is MSACAL.Calendar not MSACAL.Calander

Yotam
0
 

Author Comment

by:ArtBarnwell
ID: 17169835
Yes, but I made the typo here when I created this post and not in the code.  The code as copied directly from my module is:
Dim calControl As Control
Set calControl = fSetup.Controls.Add("MSACAL.Calendar.1", "calControl", True)




0
 
LVL 7

Accepted Solution

by:
yotamsher earned 500 total points
ID: 17171303
Hey

found this code snppet in the internet (somehow I lost the link (sorry))

Dim Usf As Object
Dim Obj As MSACal.Calendar
Set Usf = ThisWorkbook.VBProject.VBComponents("Userform1")
Set Obj = Usf.Designer.Controls.Add("MSCAL.Calendar.7")
With Obj
.Left = 20: .Top = 20: .Width = 200: .Height = 150
End With
VBA.UserForms.Add (Usf.Name)
UserForms(0).Show

I can't test it right now, but it is worth a try

Yotam
0

Featured Post

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A short article about a problem I had getting the GPS LocationListener working.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Starting up a Project

729 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question