Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6
Default Embedded ActiveX controls

I am trying to manipulate some embedded activeX controls
(comboBox) on a worksheet. Refer some sample coded below:

Dim w As Worksheet
Set w = ActiveWorkbook.Worksheets("help")
ActiveWorkbook.Worksheets("help").cboX.AddItem = "test"
w.cboX.AddItem = "again"

Line 3 works fine, and adds the text "help" to the combo
box.

Line 4 which I would have thought was identical, fails
even to compile!

Due to the nature of the task at hand it will be much
neater if I can get the code given (or like) line 4 to
work. Any ideas?

Thanks

Jack
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Embedded ActiveX controls

Jack,

Try

w.OLEObjects("cboX").Object.AddItem "test2"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Jack Clift" wrote in
message ...
I am trying to manipulate some embedded activeX controls
(comboBox) on a worksheet. Refer some sample coded below:

Dim w As Worksheet
Set w = ActiveWorkbook.Worksheets("help")
ActiveWorkbook.Worksheets("help").cboX.AddItem = "test"
w.cboX.AddItem = "again"

Line 3 works fine, and adds the text "help" to the combo
box.

Line 4 which I would have thought was identical, fails
even to compile!

Due to the nature of the task at hand it will be much
neater if I can get the code given (or like) line 4 to
work. Any ideas?

Thanks

Jack



  #3   Report Post  
Posted to microsoft.public.excel.programming
No Name
 
Posts: n/a
Default Embedded ActiveX controls

Thanks Chip,

have tried and works fine. BTW, what is the effective
difference between the two lines of code quoted below
(i.e. why does one work and not the other?)

Curious,

Jack
-----Original Message-----
Jack,

Try

w.OLEObjects("cboX").Object.AddItem "test2"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Jack Clift" wrote

in
message ...
I am trying to manipulate some embedded activeX controls
(comboBox) on a worksheet. Refer some sample coded

below:

Dim w As Worksheet
Set w = ActiveWorkbook.Worksheets("help")
ActiveWorkbook.Worksheets("help").cboX.AddItem

= "test"
w.cboX.AddItem = "again"

Line 3 works fine, and adds the text "help" to the combo
box.

Line 4 which I would have thought was identical, fails
even to compile!

Due to the nature of the task at hand it will be much
neater if I can get the code given (or like) line 4 to
work. Any ideas?

Thanks

Jack



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Embedded ActiveX controls

Jack,

It is a matter of early versus late binding. In the line of code

ActiveWorkbook.Worksheets("help").cboX.AddItem "Test"

Worksheets("Help") returns a generic Object type variable, and so
the compiler issues code to find cboX at run time, which it does
successfully and the code works as expected. This is late
binding.

In the line of code

w.cboX.AddItem "again"

w is defined as a Worksheet type variable, and the Worksheet
object does not support a method or property named cboX, so the
compiler chokes with an error. This is early binding. You can
make this line of code work by declaring w As Object rather than
As Worksheet. This causes the compiler to late bind the cboX
property, and the code will execute successfully.

Dim w As Object
w.cboX.AddItem "again"



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com



wrote in message
...
Thanks Chip,

have tried and works fine. BTW, what is the effective
difference between the two lines of code quoted below
(i.e. why does one work and not the other?)

Curious,

Jack
-----Original Message-----
Jack,

Try

w.OLEObjects("cboX").Object.AddItem "test2"


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com

"Jack Clift" wrote

in
message ...
I am trying to manipulate some embedded activeX controls
(comboBox) on a worksheet. Refer some sample coded

below:

Dim w As Worksheet
Set w = ActiveWorkbook.Worksheets("help")
ActiveWorkbook.Worksheets("help").cboX.AddItem

= "test"
w.cboX.AddItem = "again"

Line 3 works fine, and adds the text "help" to the combo
box.

Line 4 which I would have thought was identical, fails
even to compile!

Due to the nature of the task at hand it will be much
neater if I can get the code given (or like) line 4 to
work. Any ideas?

Thanks

Jack



.



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
ActiveX Controls leerem Excel Discussion (Misc queries) 0 December 11th 08 01:11 PM
Tab between ActiveX controls Tekhnikos Excel Discussion (Misc queries) 0 August 12th 08 03:42 PM
ActiveX controls Luke Excel Discussion (Misc queries) 1 October 26th 06 02:00 PM
ActiveX Controls Charly Excel Discussion (Misc queries) 1 October 18th 06 01:53 PM
ActiveX Controls vs Form Controls Alex Excel Discussion (Misc queries) 1 January 11th 06 08:46 AM


All times are GMT +1. The time now is 08:29 AM.

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

About Us

"It's about Microsoft Excel"