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

Thanks very much for your patience Tom! :-)

Sorry mate, after finally getting the app back to the all-XP machine and
testing it the code all works great thanks!!!
Was too worried about it not working that I didn't actually test the end
product on the machine in question!!

My brain and eyes are seriously fried from so much time spent on this, sorry
for this.

THanks very much

Matt


"Tom Ogilvy" wrote in message
...
To simplify:
do your development in xl97. as part of that, set the reference.

Now you should be able to use the workbook/code in any version, xl97 or
later.

I don't know what ["broke" in 2002] means.

--
Regards,
Tom Ogilvy


"Matt Jensen" wrote in message
...
I'm confused Tom, but if my understanding of terminology is correct then

the
reference may be set in either 97 or 2002, and that code "broke" in 2002
with default settings which I won't be able to alter on other
workstations...

"Tom Ogilvy" wrote in message
...
References are maintained at the workbook level. So if you have the
reference set in xl97, when you send the file to another version, it

should
cause the reference to be set to the latest version of that reference.

So I don't think you need to do anything. The code will do the
synchronization, but it should only be slightly redundant in later

versions,
so probably not worth doing anything special. You will still want to

rename
the checkboxes in all versions - running the code

unaltered/unsupplemented
for version of excel should achieve that.

--
Regards,
Tom Ogilvy

"Matt Jensen" wrote in message
...
I am aware of the synchronisation however since this app will be

deployed
on
both 97 and up at the same time then using the code you kindly

provided
I'll
need to either wrap it with a xl-version-if-statement or

programmatically
add a form won't I - I guess the former is preferable though.

quick google search showed some code to use of:
If Val(Application.Version) <= 8 Then
' user is in 97 or earlier
End If


Matt

"Tom Ogilvy" wrote in message
...
In later versions of Excel you shouldn't have to do it. Excel
automatically
synchronizes the Name property of the Control and the OleObject
container.

--
Regards,
Tom Ogilvy

"Matt Jensen" wrote in

message
...
Great thanks Tom - your were right.
Guess I'll have to programmatically add and delete a form for

the
later
versions of excel to eliminate this problem when they are

used...
Cheers
Matt

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














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:16 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"