top of page

Professional Group

Public·19 members

How to Download Microsoft MonthView Control 6.0 for Excel VBA


How to Download Microsoft MonthView Control 6.0 for Excel VBA




If you are an Excel VBA developer, you may have encountered situations where you need to allow users to select a date from a calendar. For example, you may want to create a userform that collects some data from users, such as their name, email, and date of birth. Or you may want to create a worksheet that displays some information based on a date range selected by users.




download microsoft monthview control 6.024



One way to achieve this functionality is to use the Microsoft MonthView Control 6.0, which is an ActiveX control that provides a graphical interface for selecting dates. The control displays a monthly calendar that lets users navigate through months and years, and select one or more dates. The control also supports various properties and methods that allow you to customize its appearance and behavior.


In this article, we will show you how to download, install, and use the Microsoft MonthView Control 6.0 for Excel VBA. We will also cover some alternatives and solutions that you can use if you encounter any problems or limitations with the control.


Requirements and Compatibility




Before you can use the Microsoft MonthView Control 6.0 for Excel VBA, you need to make sure that you have the following prerequisites:


  • A Windows operating system (Windows 7 or later)



  • A Microsoft Office suite (Office 2010 or later)



  • A Visual Basic for Applications (VBA) editor (included in Office)



  • An Internet connection (to download the control)



However, not all versions of Windows and Office support the Microsoft MonthView Control 6.0. The control is compatible with only 32-bit versions of Windows and Office. If you have a 64-bit version of Windows or Office, you will not be able to use the control.


To check your system bitness, you can follow these steps:


  • Right-click on the Start button and select System.



  • Under Device specifications, look for System type.



  • If it says 32-bit operating system, x86-based processor, then you have a 32-bit version of Windows.



  • If it says 64-bit operating system, x64-based processor, then you have a 64-bit version of Windows.



To check your Office bitness, you can follow these steps:


  • Open any Office application, such as Excel.



  • Click on File and select Account.



  • Under Product Information, click on About Excel (or any other application).A dialog box will appear that shows the version and bitness of your Office application.



  • If it says Microsoft Excel 2010 (32-bit) or Microsoft Excel 2013 (32-bit), then you have a 32-bit version of Office.



  • If it says Microsoft Excel 2010 (64-bit) or Microsoft Excel 2013 (64-bit), then you have a 64-bit version of Office.



If you have a 64-bit version of Windows or Office, you can either downgrade to a 32-bit version, or use an alternative solution for date selection, which we will discuss later in this article.


Installation Steps




Once you have verified that you have a compatible system, you can proceed to download and install the Microsoft MonthView Control 6.0 for Excel VBA. The installation steps are as follows:




  • Extract the contents of the mscomct2.cab file to a folder on your computer. You can use any file compression software, such as WinZip or 7-Zip, to extract the file. You should see two files in the folder: mscomct2.inf and mscomct2.ocx.



  • Right-click on the mscomct2.inf file and select Install. This will install the Microsoft MonthView Control 6.0 on your computer.



  • Next, you need to register the mscomct2.ocx file in Windows. To do this, you need to run a command prompt as an administrator. You can follow these steps:



  • Click on the Start button and type cmd in the search box.



  • Right-click on Command Prompt and select Run as administrator.



  • A User Account Control dialog box may appear asking for your permission. Click on Yes to continue.



  • In the command prompt window, type the following command and press Enter: regsvr32 "C:\Windows\System32\mscomct2.ocx"



  • Note: If you have installed the mscomct2.ocx file in a different folder, you need to replace C:\Windows\System32 with the correct path.



  • You should see a message saying that the registration was successful.



  • Now, you need to add the Microsoft MonthView Control 6.0 to your Excel VBA toolbox. To do this, you need to open the VBA editor in Excel. You can follow these steps:



  • Open Excel and create a new workbook or open an existing one.



  • Press Alt + F11 to open the VBA editor window.



  • In the VBA editor window, click on Insert and select UserForm.



  • A blank userform will appear in the editor.



  • Right-click on the toolbox (the panel with various controls) and select Additional Controls.



  • A dialog box will appear with a list of available controls. Scroll down and look for Microsoft MonthView Control 6.0.



  • Check the box next to Microsoft MonthView Control 6.0 and click on OK.



  • You should see a new control icon in the toolbox that looks like a calendar.



  • Congratulations! You have successfully installed and added the Microsoft MonthView Control 6.0 to your Excel VBA toolbox. You can now insert the control in your userform or worksheet as needed.



Usage and Customization


Now that you have installed and added the Microsoft MonthView Control 6.0 to your Excel VBA toolbox, you can use it to create a date picker in your userform or worksheet. In this section, we will show you how to use the control and customize it according to your needs.


How to use the control to select a date from a calendar




The Microsoft MonthView Control 6.0 is very easy to use. You can simply drag and drop the control from the toolbox to your userform or worksheet, and resize it as needed. The control will display a monthly calendar that shows the current date by default. You can use the arrows on the top of the control to navigate through months and years, and click on any date to select it. You can also select multiple dates by holding the Ctrl key while clicking on the dates, or by dragging the mouse over a range of dates.


When you select a date or a range of dates, the control will highlight them with a blue color, and show the selected date or dates in the bottom of the control. You can also see the selected date or dates in the Properties window of the VBA editor, under the Value property of the control. The Value property returns a Variant data type that contains either a single Date value or an array of Date values, depending on how many dates you have selected.


You can also change the selected date or dates programmatically by using the Value property of the control. For example, you can use the following code to set the selected date to January 1, 2023:


MonthView1.Value = DateSerial(2023, 1, 1)


Or you can use the following code to set the selected dates to January 1, 2023 and January 31, 2023:


MonthView1.Value = Array(DateSerial(2023, 1, 1), DateSerial(2023, 1, 31))


How to link the control to a cell or a variable




One of the most common uses of the Microsoft MonthView Control 6.0 is to link it to a cell or a variable in Excel VBA, so that you can store and retrieve the selected date or dates from the control. For example, you may want to link the control to a cell in your worksheet, so that when you select a date from the control, it will automatically update the cell value with the selected date, and vice versa.


To link the control to a cell or a variable, you need to use two events of the control: DateClick and DateChange. The DateClick event occurs when you click on a date in the control, and the DateChange event occurs when you change the selected date or dates in the control by using any method (such as clicking, dragging, or using code). You can use these events to write some code that will synchronize the value of the control with the value of the cell or variable.


For example, suppose you have inserted a Microsoft MonthView Control 6.0 named MonthView1 in your worksheet, and you want to link it to cell A1. You can use the following code in your worksheet module:


Private Sub MonthView1_DateClick(ByVal DateClicked As Date)


'This event occurs when you click on a date in MonthView1


'It will update cell A1 with the selected date


Range("A1").Value = MonthView1.Value


End Sub


Private Sub MonthView1_DateChange(ByVal StartDate As Date, ByVal EndDate As Date)


'This event occurs when you change the selected date or dates in MonthView1


'It will update cell A1 with the selected date or dates


Range("A1").Value = MonthView1.Value


End Sub


Private Sub Worksheet_Change(ByVal Target As Range)


'This event occurs when you change any cell value in this worksheet


'It will check if cell A1 has changed and update MonthView1 accordingly


If Target.Address = "$A$1" Then


MonthView1.Value = Range("A1").Value


End If


End Sub With this code, you can achieve a two-way link between MonthView1 and cell A1. Whenever you select a date or dates from MonthView1, cell A1 will show the same value. And whenever you enter a valid date or dates in cell A1, MonthView1 will show the same selection. This way, you can use the control and the cell interchangeably to work with dates.


You can also link the control to a variable in your VBA code, instead of a cell. For example, suppose you have declared a variable named SelectedDate in your userform module, and you want to link it to MonthView1. You can use the following code in your userform module:


Dim SelectedDate As Variant 'Declare a variable to store the selected date or dates


Private Sub MonthView1_DateClick(ByVal DateClicked As Date)


'This event occurs when you click on a date in MonthView1


'It will update SelectedDate with the selected date


SelectedDate = MonthView1.Value


End Sub


Private Sub MonthView1_DateChange(ByVal StartDate As Date, ByVal EndDate As Date)


'This event occurs when you change the selected date or dates in MonthView1


'It will update SelectedDate with the selected date or dates


SelectedDate = MonthView1.Value


End Sub


With this code, you can achieve a one-way link between MonthView1 and SelectedDate. Whenever you select a date or dates from MonthView1, SelectedDate will store the same value. You can then use SelectedDate in your other VBA procedures as needed.


How to change the appearance and behavior of the control




The Microsoft MonthView Control 6.0 also supports various properties and methods that allow you to change its appearance and behavior. You can access these properties and methods in the Properties window of the VBA editor, or by using code. Here are some of the most useful properties and methods that you can use:


  • BackColor: This property sets or returns the background color of the control. You can use any color value that is recognized by VBA, such as vbRed, vbGreen, or vbBlue, or use RGB values, such as RGB(255, 0, 0).



  • ForeColor: This property sets or returns the foreground color of the control, which is used for the text and grid lines. You can use the same color values as BackColor.



  • TitleBackColor: This property sets or returns the background color of the title area of the control, which shows the month and year. You can use the same color values as BackColor.



  • TitleForeColor: This property sets or returns the foreground color of the title area of the control. You can use the same color values as ForeColor.



  • MonthBackColor: This property sets or returns the background color of the month area of the control, which shows the days of the month. You can use the same color values as BackColor.



  • MonthForeColor: This property sets or returns the foreground color of the month area of the control. You can use the same color values as ForeColor.



  • DayBold: This property sets or returns an array of Boolean values that indicate whether each day in the month is displayed in bold font. You can use this property to highlight certain days in the calendar, such as holidays or special events.



  • ShowToday: This property sets or returns a Boolean value that indicates whether the current date is displayed at the bottom of the control. The default value is True.



  • ShowTodayCircle: This property sets or returns a Boolean value that indicates whether a circle is drawn around the current date in the calendar. The default value is True.



  • ShowWeekNumbers: This property sets or returns a Boolean value that indicates whether week numbers are displayed on the left side of the calendar. The default value is False.



  • FirstDayOfWeek: This property sets or returns an integer value that indicates which day of the week is displayed as the first day in the calendar. The default value is vbUseSystemDayOfWeek, which uses the system settings. You can also use other constants, such as vbSunday, vbMonday, vbTuesday, etc.



  • MaxSelCount: This property sets or returns an integer value that indicates how many dates can be selected at a time in the control. The default value is 7. You can set this property to 1 if you want to allow only one date selection.



  • < to set.



To handle these errors and exceptions, you can use the On Error statement in your VBA code, which allows you to specify what action to take when an error occurs. You can use the On Error GoTo label statement to direct the execution to a specific line or label when an error occurs, or use the On Error Resume Next statement to ignore the error and continue with the next statement. You can also use the Err object to get information about the error, such as the error number, description, source, and help file.


For example, you can use the following code to handle the run-time error '380' when setting the MaxSelCount property of MonthView1:


On Error GoTo ErrorHandler 'Enable error handling


MonthView1.MaxSelCount = 10 'Set the maximum number of dates that can be selected


Exit Sub 'Exit the procedure


ErrorHandler: 'Error handling label


If Err.Number = 380 Then 'Check if the error number is 380


MsgBox "Invalid property value. Please enter a positive integer." 'Display a message box with an error message


Err.Clear 'Clear the error object


Resume Next 'Resume with the next statement


Else 'If the error number is not 380


MsgBox Err.Description 'Display a message box with the default error message


Err.Clear 'Clear the error object


End 'End the program


End If


Alternatives and Solutions




If you are unable to use the Microsoft MonthView Control 6.0 for Excel VBA, or if you are looking for some other ways to insert a date picker in your userform or worksheet, you can try some of these alternatives and solutions:


Use built-in functions or formulas to work with dates




One of the simplest ways to work with dates in Excel VBA is to use the built-in functions or formulas that Excel provides. For example, you can use the Date function to return the current date, or use the DateSerial function to return a date based on a year, month, and day. You can also use the DateValue function to convert a text string into a date value, or use the Format function to format a date value into a specific format.


You can use these functions or formulas in your VBA code, or in your worksheet cells. For example, you can use the following code to display the current date in cell A1:


Range("A1").Value = Date


Or you can use the following formula in cell A1:


=TODAY()


You can also use these functions or formulas in combination with other functions or formulas, such as IF, AND, OR, SUMIF, COUNTIF, etc., to perform various calculations and operations with dates. For example, you can use the following formula in cell A2 to calculate how many days are left until Christmas:


=DATE(YEAR(TODAY()),12,25)-TODAY()


Use third-party add-ins or tools for date selection




Another way to insert a date picker in your userform or worksheet is to use third-party add-ins or tools that provide this functionality. There are many add-ins or tools available online that you can download and install on your computer, such as Pop-up Excel Calendar, Date Picker for Excel, Excel Date Picker, etc. These add-ins or tools usually offer more features and options than the Microsoft MonthView Control 6.0, such as compatibility with 64-bit versions of Windows and Office, support for multiple languages and formats, customization of colors and fonts, etc.


To use these add-ins or tools, you need to follow their installation and usage instructions, which may vary depending on the add-in or tool that you choose. You may also need to pay a fee or register for some of these add-ins or tools. You can search online for more information and reviews about these add-ins or tools before you decide which one to use.


Conclusion




In this article, we have shown you how to download, install, and use the Microsoft MonthView Control 6.0 for Excel VBA. We have also covered some alternatives and solutions that you can use if you encounter any problems or limitations with the control.


The Microsoft MonthView Control 6.0 is a useful and powerful tool for date selection in your userform or worksheet. It allows you to display a monthly calendar that lets users navigate through months and years, and select one or more dates. It also supports various properties and methods that allow you to customize its appearance and behavior.


However, the control is not compatible with 64-bit versions of Windows and Office, and may encounter some errors and exceptions. Therefore, you may need to use some alternatives and solutions, such as built-in functions or formulas, or third-party add-ins or tools, to insert a date picker in your userform or worksheet.


We hope that this article has helped you learn how to use the Microsoft MonthView Control 6.0 for Excel VBA, and how to overcome its challenges. If you have any questions or feedback, please feel free to leave a comment below. We would love to hear from you!


FAQs




Here are some frequently asked questions and answers about the Microsoft MonthView Control 6.0 for Excel VBA:


Q: How can I change the language or format of the dates displayed in the control?


  • A: You can change the language or format of the dates displayed in the control by changing the regional settings of your Windows system. To do this, you can follow these steps:



  • Click on the Start button and select Control Panel.



  • Under Clock, Language, and Region, click on Change date, time, or number formats.



  • A dialog box will appear with various options for changing the regional settings.



  • Under Formats, you can select a different format from the drop-down list, or click on Additional settings to customize the format.



Under Location, you can select a different country or region from the


About

Welcome to the group! You can connect with other members, ge...
bottom of page