Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

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


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

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




  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

Looks beautiful - thank you very much Bob!
Cheers mate
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






  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

Matt,

Did you ever get my tooltips code?

Bob


"Matt Jensen" wrote in message
...
Looks beautiful - thank you very much Bob!
Cheers mate
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








  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

Ahh yes I did thanks Bob
You actually sent it to a different email address to the first time you sent
it and hence I missed it until I just checked now, but got it now, will have
to go thru it yet, looks good though - thanks very much Bob
Cheers
Matt


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

Did you ever get my tooltips code?

Bob


"Matt Jensen" wrote in message
...
Looks beautiful - thank you very much Bob!
Cheers mate
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












  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

I thought that might be the case as I lost your email request and found the
address I posted to somewhere else. Post directly if you have any problems.

Regards

Bob

"Matt Jensen" wrote in message
...
Ahh yes I did thanks Bob
You actually sent it to a different email address to the first time you

sent
it and hence I missed it until I just checked now, but got it now, will

have
to go thru it yet, looks good though - thanks very much Bob
Cheers
Matt


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

Did you ever get my tooltips code?

Bob


"Matt Jensen" wrote in message
...
Looks beautiful - thank you very much Bob!
Cheers mate
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












  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

Hey Bob
Adjusted code as advised and it doesn't seem to be taking effect in xl97...?

Code looks like this:

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
ws.OLEObjects(.Name).Name = .Name
.LinkedCell =
Worksheets("Data-PMProducts-LinkedCells"). _

Range("anchorpoint_LinkedCells").Cells(i,j).Addres s(external:=True)
With .Object
.BackColor = &H80000005
.BackStyle = fmBackStyleTransparent
.Caption = ""
End With
End With

It's definitely not taking effect, and code is definitely all being executed
(I changed the .Name = "cb_r" & i & "c" & j to .Name = "NewName_cb_r" & i
& "c" & j ) to make sure and this name change did occur but in the
properties dialogue it is only still saying checkbox1 etc. for the name
attribute of my checkboxes...
Any ideas?
Thanks
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






  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

No errors either btw
matt

Adjusted code as advised and it doesn't seem to be taking effect in

xl97...?


  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

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






  #10   Report Post  
Posted to microsoft.public.excel.programming
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










  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 113
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

Thanks Tom
Sorry I don't know the equivalent of :

Dim cb1 as MsForms.Checkbox

when on a worksheet instead of a userform (as in my case)?
Thanks
Matt

"Tom Ogilvy" wrote in message
...
' 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










  #12   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

This is written for a worksheet. There is no need to change it.

--
Regards,
Tom Ogilvy

"Matt Jensen" wrote in message
...
Thanks Tom
Sorry I don't know the equivalent of :

Dim cb1 as MsForms.Checkbox

when on a worksheet instead of a userform (as in my case)?
Thanks
Matt

"Tom Ogilvy" wrote in message
...
' 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












  #13   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Programmatically set Excel 97 Control Toobar Checkbox object & container name

Here is a tested example that does what you want. I modified some of your
original code since I didn't want to try and recreate your layout.

If you get an error on the line
Dim cb1 as MsForms.Checkbox

then go to Tools=References and create a reference to the MSforms 2.0
library. Or insert a userform and the reference will be created
automatically. This is really more applicable in later versions of excel -
xl97 should already have the reference.

Sub Tester2()
Dim cb As OLEObject
Dim cb1 As MSForms.CheckBox
Dim i As Long, j As Long
Dim ws As Worksheet, obj As OLEObject
For Each obj In ActiveSheet.OLEObjects
obj.Delete
Next
Set ws = ActiveSheet
For i = 3 To 4
For j = 4 To 8 Step 3
Set cell = Cells(i, j)
Set cb = ws.OLEObjects.Add(ClassType:="Forms.CheckBox.1", _
Left:=cell.Left, _
Top:=cell.Top, _
Width:=cell.Width, _
Height:=cell.Height, _
DisplayAsIcon:=False)
Set cb1 = cb.Object
cb1.Name = "cb_r" & i & "c" & j
cb.Name = cb1.Name
cb.LinkedCell = _
ws.Cells(i, j).Address(external:=True)
With cb1
.BackColor = &H80000005
.BackStyle = fmBackStyleTransparent
.Caption = ""
End With

Next j
Next i

End Sub

--
Regards,
Tom Ogilvy

"Matt Jensen" wrote in message
...
Thanks Tom
Sorry I don't know the equivalent of :

Dim cb1 as MsForms.Checkbox

when on a worksheet instead of a userform (as in my case)?
Thanks
Matt

"Tom Ogilvy" wrote in message
...
' 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












Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
HOW DO I GIVE A CONTROL TOOLBOX CHECKBOX A VALUE IN EXCEL? Paula Excel Worksheet Functions 0 March 6th 06 04:31 PM
how to delete or remove checkbox form control in Excel? tubbekans Excel Discussion (Misc queries) 1 December 14th 05 08:51 PM
URGENT : How to get CHECKBOX object value from a Excel Worksheet by a C# Class No Name Excel Programming 0 November 22nd 04 09:06 AM
Excel - adding control programmatically. Alan B[_3_] Excel Programming 3 December 5th 03 04:34 PM
OLE Container Control in VB.NET Yi[_2_] Excel Programming 5 October 14th 03 02:41 AM


All times are GMT +1. The time now is 10:20 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"