mercredi 7 septembre 2016

Add checkbox in Excel with Poweshell

I'm trying to add form control checkboxes in Excel with Powershell. I managed to do it using the following code

$CheckBoxes = $ExcelWorkSheet.CheckBoxes()
$checkbox = $CheckBoxes.Add(Left,Top,Width,Height).Value = 1
#Left,Top,Width,Height are numbers

My problem is that I get caption for the checkbox next to it. When I do

$checkbox = $CheckBoxes.Add(Left,Top,Width,Height).Caption = ""

I get no caption but the checkbox is not checked and I need it checked.

I tried

$checkbox = $CheckBoxes.Add(Left,Top,Width,Height).Caption("").Value(1)

$checkbox1 = $CheckBoxes.Add(500,500,2,5)
$checkbox1 = $CheckBoxes.Caption = ""
$checkbox1 = $CheckBoxes.Value = 1

With no luck. Even when setting the width to 0 I still see "chec" next to it

My question is. How can I add the checkbox with no caption and checked?




Aucun commentaire:

Enregistrer un commentaire