Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Wrong type of Listbox from VBA

Hello group,

I am using this code to generate a listbox in a worksheet.
The only problem is that the listbox is from the Forms toolbar.
================================================== ===================
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", Link:=False,
DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, Height:=125.25)
..Select
Application.CommandBars("Control Toolbox").Visible = False
================================================== ====================

I require the Linked Cell function of the Control Listbox .
I used the Macro record for this code.

Thanks,

Michael Singmin

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Wrong type of Listbox from VBA

Even though it says: Forms.listbox.1, it's from the control toolbox toolbar.

But this worked ok for me:

Option Explicit
Sub testme()

Dim OLEObj As OLEObject

Set OLEObj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", _
Link:=False, DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, _
Height:=125.25)

With OLEObj
.ListFillRange = ActiveSheet.Range("a1:a10").Address(external:=True )
.LinkedCell = ActiveSheet.Range("b1").Address(external:=True)
End With
End Sub


Michael Singmin wrote:

Hello group,

I am using this code to generate a listbox in a worksheet.
The only problem is that the listbox is from the Forms toolbar.
================================================== ===================
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", Link:=False,
DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, Height:=125.25)
.Select
Application.CommandBars("Control Toolbox").Visible = False
================================================== ====================

I require the Linked Cell function of the Control Listbox .
I used the Macro record for this code.

Thanks,

Michael Singmin


--

Dave Peterson

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Wrong type of Listbox from VBA

Well done Dave,

Again, I have learnt something new and valuable.
Much appreciated.

Michael
================================================== ====================
Dave Peterson wrote:

Even though it says: Forms.listbox.1, it's from the control toolbox toolbar.

But this worked ok for me:

Option Explicit
Sub testme()

Dim OLEObj As OLEObject

Set OLEObj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", _
Link:=False, DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, _
Height:=125.25)

With OLEObj
.ListFillRange = ActiveSheet.Range("a1:a10").Address(external:=True )
.LinkedCell = ActiveSheet.Range("b1").Address(external:=True)
End With
End Sub


Michael Singmin wrote:

Hello group,

I am using this code to generate a listbox in a worksheet.
The only problem is that the listbox is from the Forms toolbar.
================================================== ===================
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", Link:=False,
DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, Height:=125.25)
.Select
Application.CommandBars("Control Toolbox").Visible = False
================================================== ====================

I require the Linked Cell function of the Control Listbox .
I used the Macro record for this code.

Thanks,

Michael Singmin


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 60
Default Wrong type of Listbox from VBA

Hello again Dave,

I notice the listbox is not alive after I run this code. It does not
respond if I click it. What I have to do to wake it up, is to go
manually in and out of design mode (Control toolbar).

Also, what is the purpose of the (external:=true) in the code ?

Thanks,

Michael


Dave Peterson wrote:

Even though it says: Forms.listbox.1, it's from the control toolbox toolbar.

But this worked ok for me:

Option Explicit
Sub testme()

Dim OLEObj As OLEObject

Set OLEObj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", _
Link:=False, DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, _
Height:=125.25)

With OLEObj
.ListFillRange = ActiveSheet.Range("a1:a10").Address(external:=True )
.LinkedCell = ActiveSheet.Range("b1").Address(external:=True)
End With
End Sub


Michael Singmin wrote:

Hello group,

I am using this code to generate a listbox in a worksheet.
The only problem is that the listbox is from the Forms toolbar.
================================================== ===================
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", Link:=False,
DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, Height:=125.25)
.Select
Application.CommandBars("Control Toolbox").Visible = False
================================================== ====================

I require the Linked Cell function of the Control Listbox .
I used the Macro record for this code.

Thanks,

Michael Singmin


  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,824
Default Wrong type of Listbox from VBA

Maybe you're in design mode.

Show that control toolbox toolbar and toggle the "design mode" icon. (Top left
corner of the toolbar.)

try a simple test:

msgbox range("a1").address
and
msgbox range("a1").address(external:=true)

You'll see that with external:=true, you get the workbook name, worksheet name
and cell address.

So I guess it's just one way of making sure that you're using the range you want
to use.

Michael Singmin wrote:

Hello again Dave,

I notice the listbox is not alive after I run this code. It does not
respond if I click it. What I have to do to wake it up, is to go
manually in and out of design mode (Control toolbar).

Also, what is the purpose of the (external:=true) in the code ?

Thanks,

Michael

Dave Peterson wrote:

Even though it says: Forms.listbox.1, it's from the control toolbox toolbar.

But this worked ok for me:

Option Explicit
Sub testme()

Dim OLEObj As OLEObject

Set OLEObj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", _
Link:=False, DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, _
Height:=125.25)

With OLEObj
.ListFillRange = ActiveSheet.Range("a1:a10").Address(external:=True )
.LinkedCell = ActiveSheet.Range("b1").Address(external:=True)
End With
End Sub


Michael Singmin wrote:

Hello group,

I am using this code to generate a listbox in a worksheet.
The only problem is that the listbox is from the Forms toolbar.
================================================== ===================
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", Link:=False,
DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, Height:=125.25)
.Select
Application.CommandBars("Control Toolbox").Visible = False
================================================== ====================

I require the Linked Cell function of the Control Listbox .
I used the Macro record for this code.

Thanks,

Michael Singmin


--

Dave Peterson



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default Wrong type of Listbox from VBA

? ActiveSheet.Range("a1:a10").Address(external:=True )
[Book3]Sheet2!$A$1:$A$10
? activesheet.Range("A1:a10").Address
$A$1:$A$10

--
Regards,
Tom Ogilvy

"Michael Singmin" wrote in message
...
Hello again Dave,

I notice the listbox is not alive after I run this code. It does not
respond if I click it. What I have to do to wake it up, is to go
manually in and out of design mode (Control toolbar).

Also, what is the purpose of the (external:=true) in the code ?

Thanks,

Michael


Dave Peterson wrote:

Even though it says: Forms.listbox.1, it's from the control toolbox

toolbar.

But this worked ok for me:

Option Explicit
Sub testme()

Dim OLEObj As OLEObject

Set OLEObj = ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1",

_
Link:=False, DisplayAsIcon:=False, Left:=114, Top:=105,

Width:=90, _
Height:=125.25)

With OLEObj
.ListFillRange =

ActiveSheet.Range("a1:a10").Address(external:=True )
.LinkedCell = ActiveSheet.Range("b1").Address(external:=True)
End With
End Sub


Michael Singmin wrote:

Hello group,

I am using this code to generate a listbox in a worksheet.
The only problem is that the listbox is from the Forms toolbar.
================================================== ===================
Application.CommandBars("Control Toolbox").Visible = True
ActiveSheet.OLEObjects.Add(ClassType:="Forms.ListB ox.1", Link:=False,
DisplayAsIcon:=False, Left:=114, Top:=105, Width:=90, Height:=125.25)
.Select
Application.CommandBars("Control Toolbox").Visible = False
================================================== ====================

I require the Linked Cell function of the Control Listbox .
I used the Macro record for this code.

Thanks,

Michael Singmin




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
Error: Value in Formula of wrong data type mak_nyce Excel Worksheet Functions 0 January 5th 10 06:04 PM
Wrong data type Dale Long Excel Discussion (Misc queries) 2 April 4th 09 02:35 AM
Where am I going wrong? - Date type function. mr tom Excel Worksheet Functions 10 March 8th 08 04:43 AM
Type mismatched in Listbox Wellie[_2_] Excel Programming 1 February 18th 04 06:39 PM
Populating multicolumn listbox the wrong way notsureofthatinfo Excel Programming 0 October 22nd 03 11:38 PM


All times are GMT +1. The time now is 04:33 PM.

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"