View Single Post
  #10   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

' declarations are important
Dim cb as OleObject
Dim cb1 as MsForms.Checkbox

Set cb = ws.OLEObjects.Add(ClassType:="Forms.CheckBox.1", _
Left:=intLeftLocation, _
Top:=cellUnder.Top + 2, _
Width:="13.5", _
Height:="15", _
DisplayAsIcon:=False)
set cb1 = cb.Object
cb1 .Name = "cb_r" & i & "c" & j
cb.Name = cb1.Name
cb.LinkedCell = _
Worksheets("Data-PMProducts-LinkedCells"). _
Range("anchorpoint_LinkedCells").Cells(i,j).Addres s(external:=True)
With cb1
.BackColor = &H80000005
.BackStyle = fmBackStyleTransparent
.Caption = ""
End With
End With

--
Regards,
Tom Ogilvy


"Matt Jensen" wrote in message
...
Try this in a blank workbook in xl97 - doesn't work either...
Sub test()
Dim cb As OLEObject
Dim ws As Worksheet

Set ws = Worksheets("Sheet1") 'Sheet1
ws.Activate
ws.Range("A1").Activate

Set cb = ws.OLEObjects.Add(ClassType:="Forms.CheckBox.1", _
Left:=20, _
Top:=20, _
Width:=13.5, _
Height:=15, _
DisplayAsIcon:=False)
With cb
.Name = "CheckboxName"
ws.OLEObjects(.Name).Name = .Name
End With
End Sub

Matt

"Bob Phillips" wrote in message
...
Matt,

Is this what you want?

With cb 'add other info
.Name = "cb_r" & i & "c" & j 'name the checkbox

with
it 's row and column number
ws.OLEObjects(.Name).Name = .Name
...

--

HTH

RP
(remove nothere from the email address if mailing direct)


"Matt Jensen" wrote in message
...
Howdy
Need in Excel 97 to programmatically create some control toolbar

checkboxes
and set both (I think the terminology is) the object and container

names
to
the same name "cb_r" & i & "c" & j
What code do I need to add to my snippet of my code below to set both

names?
Thanks
Matt

Set cb =
ws.OLEObjects.Add(ClassType:="Forms.CheckBox.1", _
Left:=intLeftLocation, _
Top:=cellUnder.Top + 2, _
Width:="13.5", _
Height:="15", _
DisplayAsIcon:=False)
With cb 'add other info
.Name = "cb_r" & i & "c" & j 'name the

checkbox
with
it's row and column number
.LinkedCell =
Worksheets("Data-PMProducts-LinkedCells"). _

Range("anchorpoint_LinkedCells").Cells(i,
j).Address(external:=True)

.Placement = xlMove ' This lets each check box

stay
with its row during sorts. NEEDED???
With .Object
.BackColor = &H80000005
.BackStyle = fmBackStyleTransparent
.Caption = ""
End With
End With