in reply to Excel VB Controls
Each form control is a "Shape", and its values can be manipulated through the OLEFormat object.
The following sample code should put you on the right track. It will create a worksheet with a check box, check it, and then uncheck it. (If you're using something other than Excel 2003, you'll need to update the "Microsoft Excel 11.0 Object Library" to the correct version)
use strict; use Win32::OLE; use Win32::OLE::Const("Microsoft Excel 11.0 Object Library"); # Load Excel objects my $xl = Win32::OLE->new('Excel.Application'); $xl->{Visible} = 1; my $book = $xl->Workbooks->Add; my $sheet = $book->Worksheets->Add; # Add a check box to manipulate $sheet->Shapes->AddFormControl(xlCheckBox, 0, 0, 250, 250); # Get the name of our checkbox my $chkBoxName = $sheet->Shapes(1)->Name; # Check the check box $sheet->Shapes($chkBoxName)->OLEFormat->Object->{Value} = 1; sleep 2; # Uncheck the check box $sheet->Shapes($chkBoxName)->OLEFormat->Object->{Value} = 0;
|
---|