Using DatePicker control in VBA - vba

I'm trying to add DatePicker VBA control in an PowerPoint 2007 slide. But I couldn't find any such control.
I have added Microsoft Office 12.0 Object Library as well as Microsoft Excel and Powerpoint Object Library, but still I couldn't find any control related to DatePicker.
I'd love if someone can direct me to some article or documentation, tutorial to add it.

The control isn't included with Office/VBA. If it's installed on your PC, the answer posted by Jean-François Corbett will get you there, but your code won't work on other PCs unless they also have the needed control installed.
Have a look here:
http://www.excelbanter.com/showthread.php?t=241456

Is this what you want?
Developer > Controls > More controls... (the hammer-and-wrench icon) > Microsoft MonthView Control

Related

How to add a WebView2 Control (To replace the old unsupported WebBrowser Control) into VBA form in 2022?

I want to add a control to a VBA form that displays a preview of an Excel 365 online file once the user clicks on the file name in a list. I did this successfully in the past using WebBrowser Control:
Now the problem is that this WebBrowser control is based on the extremely old Microsoft Explorer 11. Accordingly as of March 2022 this control stopped previewing Excel 365 online files and instead is showing a blank page. So it is working, but not properly since it is based on a very old technology.
I did some research and found out that this control has been replaced by Microsoft WebView2 which is much more modern but I cannot find a reference for it at all in VBA and don't know how to add this control to my VBA form.
Can someone let me know how to display webpages properly on a VBA form in 2022? Thanks! :-)

VSTO Addin - Own button type like "ShapeWidth" and "ShapeHeight"

I am currently working on an PowerPoint Addin and I am currently finishing the Ribbon. I'd like to create a control to change the size of objects that looks similar to the inbuild button "ShapeWidth" and "ShapeHeight":
However, I couldn't find the correct control type and hence I built the below by myself using an editbox and buttons. Although it's working I find the other style way cleaner but I haven't found the correct type.
Not all Ribbon X (Office Fluent UI) control types that Microsoft uses in its Office applications are made available to third-party developers. This, I'm afraid, falls into that category.
You should probably be able to get the image, at least, by specifying the idMso for the built-in control.

Conditional Ribbon Tab Label based on Office version

Developing an addin for Microsoft Office 2007 onwards (client requirements, yuck) but I am rusty with my VB. I am using Visual Studio 2008 to create the addin for all 3 major programs; Word, Excel and PowerPoint.
I was wanting to set a condition to rename the Tab inside of the Ribbon depending on what version of office they were running. But I have searched everywhere and cannot seem to find a way to accomplish this? I don't quite understand what Ribbon XML is and how it differs from the visual designer.
It would be great to get some explanation of how to access elements of the Ribbon and change them depending on the Application Version (whenever I try to reference Application.Version VB doesn't seem to know what I am talking about)
I can clarify more however any help including 'where to look' would be much appreciated, thank you :)

Word Add-in - find if dialog has focus?

I am writing a word add-in in VB .NET (using Add-in Express, but I don't think that's relevant).
I have created shortcuts, but I only want them to take effect if the document itself is in focus, not a dialog - for example, "Find and replace" or any other.
How do I determine if a dialog has focus?
The "Selection" property of the application points to the selection in the document, even if a dialog is currently selected. I can't find any "HasFocus"-equivalent property anywhere either. I'm running out of ideas :o)
Thanks!
This workaround worked for me:
My add-in keeps a reference to the handle of the most recently activated Word window, by using the GetActiveWindow API during the WindowActivate event of the Word application. This is necessary since, up until Office 2013, the Window object does not expose a handle property.
When a shortcut is triggered, I compare that to the handle of the currently active window, using the same API. If they don't match, I simply don't proceed :o)

What form controls can a VBA project access from Office 2007?

In a VBA project, you can create a UserForm and add controls to it using the toolbox window. By default, the toolbox window contains the simple form controls such as Label, TextBox, ListBox, etc.
You can add additional controls if they're installed on your machine: right-clicking "additional controls" on the toolbox shows a whole screed of controls. However, this does not give any indication of where they came from.
I'm interested to know what controls are guaranteed to be available on a machine that has Office 2007 installed. Is it just the standard ones, or are some of the "additional controls" also guaranteed to be available (either because they come with Office 2007, or because they exist on all the versions of Windows that Office 2007 will run on)?
For example, I'm surprised that there's no treeview control even in Office 2007. In my "additional controls" list I see the "Microsoft TreeView Control v6", but I don't know whether I can rely on that being present for all my Office 2007 users.
The controls you see are part of FM20.DLL; which is part of the Office Install.
You can see that they are all part of the same DLL by looking in the "Location" portion of the "Additional Controls" box.
AFAIK, those are the only controls guaranteed available with most Office installations.
So that being said, let's see what can be done specifically for each control you ask about in your comments:
"grid" capable list
hierarchical tree view
calendar control
The Grid
It's going to come down to your requirements, but you may be able to get away with using a listbox. The listbox in VBA has a few of properties that make will make it Grid-like.
For example, let's say a worksheet in Excel looks like this:
ID001 Value 1 Description 1
ID002 Value 2 Description 2
ID003 Value 3 Description 3
The listbox supports multiple columns, so you can make these values show up by setting the listbox property ColumnCount to 3 and writing the following code:
Me.ListBox1.ColumnWidths = "50;100;200"
Me.ListBox1.RowSource = Sheet1.Range("A1:C3").Address
You will get something like this:
Want to hide a column? No problem, change the width of the ColumnWidths property to zero for the column to hide:
Me.ListBox1.ColumnWidths = "50;0;200" 'Hide column 2
What good is a grid if you can't select things from it, right?
On the listbox, change the ListStyle property to frmListStyleOption and then change MultiSelect to frmMultiSelect.
That will give you a listbox that looks more like a grid:
Calendar
08/17/2012 UPDATE:
Read this post. One of the guys who answered created his own calendar control.
A calendar control exists for Office (mscal.ocx):
However, the right conditions must be met:
Access must be installed on the clients machine
The Office version cannot be Office 2010 as it was removed with this version (See Features removed from Microsoft Access)
You can still get the calendar control to work with 2010 and/or non-Access Office installations, but it takes additional steps on the client's machine.
Download mscal.ocx
Extract it to windows/system32 directory
Register it
TreeView
If it's acceptable for you clients to install some EXEs, you could have them install Microsoft Visual Basic 6.0 Common Controls. That will give you the TreeView control.
I would be willing to bet that most machines (particularly older ones on Windows XP) already have these OCXs installed; thus the installation may not be necessary.
The biggest problem is that you're deploying OCXs on client machines and that gets frustrating from a support standpoint.