Solved

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

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
groovy example issue 10 97
Device same like our heart 12 85
control image tags in a string ? 12 131
SUM 2 INTEGER ARRAYS INTO 1 10 100
This is about my first experience with programming Arduino.
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.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

777 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