View Full Version : Solved: Auto-creating OLE Controls, e.g. Checkboxes, OptionBoxes
hewillaugh
09-13-2010, 12:36 PM
I'm looking for some guidance and examples for how to automatically create OLE objects, e.g. checkboxes & option boxes in VBA for PowerPoint. I'm currently using PowerPoint 2007 (Microsoft PowerPoint 12 Object Library).
This is the code I'm been using but keep getting an error:
Dim oPres as Presentation
Dim oSlide as Slide
Set oPres = ActivePresentation
Set oSlide = oPres.Slides(1)
oSlide.Shapes.AddOLEObject Left:=1, Top:=1, ClassName:="OLEObjects.CheckBox"
Mainly, what is the Class Name convention for OLE Objects?
Any help is much appreciated! Thanks in advance for your consideration.
Paul_Hossler
09-13-2010, 04:43 PM
Wecome
Option Explicit
Sub drv()
Dim oPres As Presentation
Dim oSlide As Slide
Set oPres = ActivePresentation
Set oSlide = oPres.Slides(1)
oSlide.Shapes.AddOLEObject Left:=1, Top:=1, ClassName:="Forms.CheckBox.1"
End Sub
I don't know why ... it just is :-)
Paul
hewillaugh
09-15-2010, 03:15 PM
Thanks, Paul. That worked! It is curious--where do you find the documentation to do this kind of stuff?
One related question, do you have code to set the value of an optionbox to "false"?
Paul_Hossler
09-15-2010, 06:11 PM
1. I never did find a list of ClassNames, but using the Help for 'AddOLEobject' ...
This example adds a command button to myDocument.
Visual Basic for ApplicationsSet myDocument = ActivePresentation.Slides(1)myDocument.Shapes.AddOLEObject Left:=100, Top:=100, _ Width:=150, Height:=50, ClassName:="Forms.CommandButton.1"
there was a ClassName, so I took a guess
2. To set/reset the value, you can use something like this
Option Explicit
Sub drv()
Dim oPres As Presentation
Dim oSlide As Slide
Dim oControl As Shape
Set oPres = ActivePresentation
Set oSlide = oPres.Slides(1)
Set oControl = oSlide.Shapes.AddOLEObject(Left:=1, Top:=1, ClassName:="Forms.CheckBox.1")
oControl.OLEFormat.Object.Value = True
End Sub
Paul
John Wilson
09-16-2010, 02:14 AM
If you insert an OLE object manually and then select and run the code below ....
Sub whatisit()
MsgBox ActiveWindow.Selection.ShapeRange(1).OLEFormat.ProgID
End Sub
Paul_Hossler
09-16-2010, 07:36 AM
If you insert an OLE object manually and then select and run the code below
1. Tricky
2. Not very intuitive
3. I was looking all through the Object Browser (VBE, F2) and could not find anything in MSForms Library that would help
Thanks
Paul
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.