
| Subject: | How to change a control's properties using OLE |
| Posted by: | Tom Field |
| Date: | Mon, 28 Jun 2010 |
Excel 2010 for some unknown reason added shadows to controls in worksheets we created in earlier versions.
The VB code at the bottom of this post removes the shadows, but I need to do it +from Delphi7+, where we have an OLE connection established by:
{code}
xlApp := CreateOLEObject('Excel.Application').
{code}
I know the worksheet and control names, so I don't need the For-Next loops in the code below.
But, can anyone suggest how to access a control (with embedded spaces in its name!) from Delphi.
Something like:
{code}
ControName := "Check Box 22";
fXlApp.ActiveWorkBook.WorkSheet[WorksheetName].Control[ControlName].ShapeRange.Shadow.Visible = msoFalse
{code}
VB code, portions of which I want to do in Delphi 7.
{code}
Public Sub RemoveShadows()
Dim chk As CheckBox
Dim btn As Button
Dim ws As Worksheet
For Each ws In ActiveWorkbook.Worksheets
For Each chk In ws.CheckBoxes
chk.ShapeRange.Shadow.Visible = msoFalse
Next chk
For Each btn In ws.Buttons
btn.ShapeRange.Shadow.Visible = msoFalse
Next btn
Next ws
End Sub
{code}