Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Need to cast OleObject to CombBbox

Hello,
I would need to cast an OleObject into a Combobox because VBA Excel doesn't
seem to do it implicitely
That is for using the AddItem method on it (this method is not supported by
the OleObject)

This is my code
' OleObject(1) is supposed to be a combobox
ActiveSheet.OleObjects(1).AddItem "Hello"

Can someone help me please ?


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Need to cast OleObject to CombBbox

OleObject(1) is supposed to be a combobox
if typeof OleObjects(1).Object is MSForms.Combobox then
ActiveSheet.OleObjects(1).Object AddItem "Hello"
End if

additem is a method of the combobox. OleObjects(1).Object is the combobox

for example:

Sub Tester3()
Dim rng As Range
Dim cell As Range
Set rng = Range(Cells(3, "A"), _
Cells(Rows.Count, "A").End(xlUp))
For Each cell In rng
ActiveSheet.OLEObjects(1).Object.AddItem cell.Text
Next

End Sub

--
Regards,
Tom Ogilvy


"Liline" wrote in message
...
Hello,
I would need to cast an OleObject into a Combobox because VBA Excel

doesn't
seem to do it implicitely
That is for using the AddItem method on it (this method is not supported

by
the OleObject)

This is my code
' OleObject(1) is supposed to be a combobox
ActiveSheet.OleObjects(1).AddItem "Hello"

Can someone help me please ?




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
Unable to cast com object (interop) yh Excel Discussion (Misc queries) 0 April 26th 10 09:16 AM
How do I cast time when the total exceeds 24 hours arm266 Excel Discussion (Misc queries) 11 September 26th 09 06:58 PM
CAST Function Matt S Excel Discussion (Misc queries) 1 February 19th 08 05:16 PM
OLEobject on the sheet Ryan[_6_] Excel Programming 1 August 3rd 03 03:15 PM
Using a variable to represent a Checkbox Name(OLEObject) Mike Cooper Excel Programming 1 July 16th 03 09:40 PM


All times are GMT +1. The time now is 10:39 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"