Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unable to fill Listbox thru VBA


Hi, I want to fill a listbox thru VBA not connecting a range to it.
Every thing I tru (such as AddItem method) result i the error msg "The
Object dosent support his method or property" Even if I copy the Excel
Help Example, why is that?

Kind regards!


--
rash
------------------------------------------------------------------------
rash's Profile: http://www.excelforum.com/member.php...o&userid=29765
View this thread: http://www.excelforum.com/showthread...hreadid=494825

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Unable to fill Listbox thru VBA

Hi Rash,

Try posting your code which fails.


---
Regards,
Norman



"rash" wrote in message
...

Hi, I want to fill a listbox thru VBA not connecting a range to it.
Every thing I tru (such as AddItem method) result i the error msg "The
Object dosent support his method or property" Even if I copy the Excel
Help Example, why is that?

Kind regards!


--
rash
------------------------------------------------------------------------
rash's Profile:
http://www.excelforum.com/member.php...o&userid=29765
View this thread: http://www.excelforum.com/showthread...hreadid=494825



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unable to fill Listbox thru VBA


Ok here it goes.
AddItem dosent work, nor dose list.

Kind regards


Code
-------------------

Dim myDoc As Worksheet
Dim list As Variant
list = ThisWorkbook.Sheets("Sheet1").Range("A2:A4").Value
Set myDoc = ThisWorkbook.Sheets("Sheet1")
myDoc.Shapes("ListBox1").list = list ' populate the listbox
myDoc.Shapes("ListBox1").ControlFormat.AddItem ("Whatever"
-------------------

Norman Jones Wrote:
Hi Rash,

Try posting your code which fails.


---
Regards,
Norman



"rash" wrote i
message
...

Hi, I want to fill a listbox thru VBA not connecting a range to it.
Every thing I tru (such as AddItem method) result i the error ms

"The
Object dosent support his method or property" Even if I copy th

Excel
Help Example, why is that?

Kind regards!


--
rash


------------------------------------------------------------------------
rash's Profile:
http://www.excelforum.com/member.php...o&userid=29765
View this thread

http://www.excelforum.com/showthread...hreadid=494825


--
ras
-----------------------------------------------------------------------
rash's Profile: http://www.excelforum.com/member.php...fo&userid=2976
View this thread: http://www.excelforum.com/showthread.php?threadid=49482

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Unable to fill Listbox thru VBA

Hi Rash,

AddItem dosent work, nor dose list.


Try:


'==============
Sub Tester01()
Dim OleObj As OLEObject
Dim SH As Worksheet
Dim rng As Range
Dim rCell As Range

Set SH = ActiveSheet
Set rng = SH.Range("A1:A20")

Set OleObj = SH.OLEObjects("ListBox1")

With OleObj
.ListFillRange = ""
.Object.Clear

For Each rCell In rng.Cells
.Object.AddItem rCell.Value
Next rCell
End With
End Sub
'<<==============

Or:

'==============
Sub Tester02()
Dim OleObj As OLEObject

Set OleObj = ActiveSheet.OLEObjects("ListBox1")
OleObj.ListFillRange = "A1:A24"

End Sub
'<<==============

---
Regards,
Norman



"rash" wrote in message
...

Ok here it goes.
AddItem dosent work, nor dose list.

Kind regards


Code:
--------------------

Dim myDoc As Worksheet
Dim list As Variant
list = ThisWorkbook.Sheets("Sheet1").Range("A2:A4").Value
Set myDoc = ThisWorkbook.Sheets("Sheet1")
myDoc.Shapes("ListBox1").list = list ' populate the listbox
myDoc.Shapes("ListBox1").ControlFormat.AddItem ("Whatever")
--------------------

Norman Jones Wrote:
Hi Rash,

Try posting your code which fails.


---
Regards,
Norman



"rash" wrote in
message
...

Hi, I want to fill a listbox thru VBA not connecting a range to it.
Every thing I tru (such as AddItem method) result i the error msg

"The
Object dosent support his method or property" Even if I copy the

Excel
Help Example, why is that?

Kind regards!


--
rash

------------------------------------------------------------------------
rash's Profile:
http://www.excelforum.com/member.php...o&userid=29765
View this thread:

http://www.excelforum.com/showthread...hreadid=494825



--
rash
------------------------------------------------------------------------
rash's Profile:
http://www.excelforum.com/member.php...o&userid=29765
View this thread: http://www.excelforum.com/showthread...hreadid=494825



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Unable to fill Listbox thru VBA

Sub abc()
v = Array(1, 2, 3, 4, 5)
ActiveSheet.OLEObjects("ListBox1").Object.List = v
End Sub

Sub abc1()
For i = 1 To 7
ActiveSheet.OLEObjects("Listbox2").Object.AddItem i
Next
End Sub

so

Dim myDoc As Worksheet
Dim list As Variant
list = ThisWorkbook.Sheets("Sheet1").Range("A2:A4").Value
Set myDoc = ThisWorkbook.Sheets("Sheet1")
myDoc.OleObjects("ListBox1").Object.list = list ' populate the listbox

' or
myDoc.OleObjects("ListBox1").Object.AddItem "Whatever"

--
Regards,
Tom Ogilvy


"rash" wrote in message
...

Ok here it goes.
AddItem dosent work, nor dose list.

Kind regards


Code:
--------------------

Dim myDoc As Worksheet
Dim list As Variant
list = ThisWorkbook.Sheets("Sheet1").Range("A2:A4").Value
Set myDoc = ThisWorkbook.Sheets("Sheet1")
myDoc.Shapes("ListBox1").list = list ' populate the listbox
myDoc.Shapes("ListBox1").ControlFormat.AddItem ("Whatever")
--------------------

Norman Jones Wrote:
Hi Rash,

Try posting your code which fails.


---
Regards,
Norman



"rash" wrote in
message
...

Hi, I want to fill a listbox thru VBA not connecting a range to it.
Every thing I tru (such as AddItem method) result i the error msg

"The
Object dosent support his method or property" Even if I copy the

Excel
Help Example, why is that?

Kind regards!


--
rash

------------------------------------------------------------------------
rash's Profile:
http://www.excelforum.com/member.php...o&userid=29765
View this thread:

http://www.excelforum.com/showthread...hreadid=494825



--
rash
------------------------------------------------------------------------
rash's Profile:

http://www.excelforum.com/member.php...o&userid=29765
View this thread: http://www.excelforum.com/showthread...hreadid=494825





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Unable to fill Listbox thru VBA


Works like a charm!

Why dose it work with OLEObject?

Kind regard

--
ras
-----------------------------------------------------------------------
rash's Profile: http://www.excelforum.com/member.php...fo&userid=2976
View this thread: http://www.excelforum.com/showthread.php?threadid=49482

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,302
Default Unable to fill Listbox thru VBA

Hi Rash,

Why dose it work with OLEObject?


An OleObject and, more particularly, a listbox, has methods and properties
whih differ from those of a shape object.

BTW, check Tom's response for some instructive code.


---
Regards,
Norman


"rash" wrote in message
...

Works like a charm!

Why dose it work with OLEObject?

Kind regards


--
rash
------------------------------------------------------------------------
rash's Profile:
http://www.excelforum.com/member.php...o&userid=29765
View this thread: http://www.excelforum.com/showthread...hreadid=494825



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 view color fill changes unless I print preview Roberto Excel Worksheet Functions 1 November 30th 05 03:02 AM
Is there an easier way to fill this listbox D[_8_] Excel Programming 3 December 31st 04 04:38 PM
R1C1 seems to effect listbox fill in VBA Steve[_59_] Excel Programming 1 May 4th 04 03:03 AM
Fill a ListBox with items using VBA [email protected] Excel Programming 1 April 21st 04 09:59 PM
For..next.. help to fill listbox jasonsweeney[_69_] Excel Programming 1 April 20th 04 09:25 PM


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