Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to set focus on an ActiveX ListBox

I am stymied trying to figure the code that sets the focus of an
ActiveX ListBox to the first name appearing in the ListBox. The
ListBox is on Sheet1.

I tried this code but get the error message "Compile Error Sub or
Function not defined"

I am using Excel 2007

Private Sub Workbook_Open()
Application.ScreenUpdating = False
Sheets("Sheet1").Select
OLEObject("ListBox1").Value = "ABC"
Application.ScreenUpdating = True
End Sub

Can anyone help me correct this code so when the workbook opens - it
displays the right sheet and the ListBox shows the focus on the first
name?

Thank you,

Rob
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default How to set focus on an ActiveX ListBox

hi Rob,

With Sheets("Sheet1").ListBox1
..ListIndex = 0
End With

--
isabelle



Le 2012-06-21 13:22, Rob Flott a écrit :
I am stymied trying to figure the code that sets the focus of an
ActiveX ListBox to the first name appearing in the ListBox. The
ListBox is on Sheet1.

I tried this code but get the error message "Compile Error Sub or
Function not defined"

I am using Excel 2007

Private Sub Workbook_Open()
Application.ScreenUpdating = False
Sheets("Sheet1").Select
OLEObject("ListBox1").Value = "ABC"
Application.ScreenUpdating = True
End Sub

Can anyone help me correct this code so when the workbook opens - it
displays the right sheet and the ListBox shows the focus on the first
name?

Thank you,

Rob

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to set focus on an ActiveX ListBox


Isabelle, thank you very much...this works great...
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default How to set focus on an ActiveX ListBox

Rob, you're welcome! ..feedback is always appreciated, thank to you!

--
isabelle




Le 2012-06-21 18:08, Rob Flott a écrit :

Isabelle, thank you very much...this works great...

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10
Default How to set focus on an ActiveX ListBox

On Jun 21, 6:07*pm, isabelle wrote:
Rob, you're welcome! ..feedback is always appreciated, thank to you!

--
isabelle

Le 2012-06-21 18:08, Rob Flott a écrit :





Isabelle, thank you very much...this works great...- Hide quoted text -


- Show quoted text -


Hi Isabelle....I spoke to soon...when I run the macro it works
fine...but when I 'call' the macro in my 'Workbook_Open()' sub I get
'Run-Time error '438' Object doesn't support this property or
method'. Ironically, when I click 'End' on this error message it runs
the macro without any problems. Any ideas as to why this happens?

Thanks Isabelle


  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 587
Default How to set focus on an ActiveX ListBox

hi Rob,

i tried it with the Workbook_Open event and i have no error,
here is my test file: http://cjoint.com/?BFwruPnWL1q
can you try it?

--
isabelle



Le 2012-06-22 10:56, Rob Flott a écrit :
On Jun 21, 6:07 pm, wrote:
Rob, you're welcome! ..feedback is always appreciated, thank to you!

--
isabelle

Le 2012-06-21 18:08, Rob Flott a écrit :





Isabelle, thank you very much...this works great...- Hide quoted text -


- Show quoted text -


Hi Isabelle....I spoke to soon...when I run the macro it works
fine...but when I 'call' the macro in my 'Workbook_Open()' sub I get
'Run-Time error '438' Object doesn't support this property or
method'. Ironically, when I click 'End' on this error message it runs
the macro without any problems. Any ideas as to why this happens?

Thanks Isabelle

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
ListBox Property where 'focus' triggers selection Tony Bender Excel Programming 1 June 8th 09 04:36 PM
ActiveX Combo Box Focus CraigB[_2_] Excel Programming 0 February 23rd 09 04:04 PM
Listbox Item Focus Kagan Clearwater[_2_] Excel Programming 1 April 5th 07 08:12 PM
ActiveX comboboxes on worksheet (lost focus problems) [email protected] Excel Programming 5 February 13th 07 03:51 PM
removing selection focus in listbox Craig Wilks[_2_] Excel Programming 2 August 13th 03 12:15 PM


All times are GMT +1. The time now is 11:09 PM.

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"