Solved

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

Posted on 2006-07-24
5
577 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
Comment Utility
I think you have a typo

it is MSACAL.Calendar not MSACAL.Calander

Yotam
0
 

Author Comment

by:ArtBarnwell
Comment Utility
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
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
fix34  challenge 9 95
thread-safe code in c++ 2 69
sumDigits  challenge 7 59
C Programming - If Statement 8 46
Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
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…

762 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now