Solved

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

Posted on 2006-07-24
5
588 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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.

730 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