Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Double Click and Item in a list box to open a sheet

Status
Not open for further replies.

orisons

Programmer
Feb 18, 2002
49
CA
Is it possible (after populating a listbox) that if the user double clicks an item in a list box that eack item will open different excel spreadsheets (excel need not be running initially). Please remember that I am relatively new at this in any reply

Thank you
 
orisons,

Is this application being written as an independent VB executable or are you writing this in Excel VBA?

Skip,

[glasses] [red]Be advised:[/red]When Viscounts were guillotined just as they were disclosing where their jewels were hidden, it shows to go that you should...
Never hatchet your Counts before they chicken! [tongue]
 
Well...

If the name of the list is list1,
the path of excel.exe is "ExcelPath"

Then:

Code:
Private Sub List1_DblClick()
  Dim ExcelPath As String
  ExcelPath = "C:\Program Files\Microsoft Office\OFFICE11\EXCEL.exe"

  Shell  ExcelPath & " " & List1.List(List1.ListIndex), 1
End Sub

The "1" means that the excel will have the focus and will be in its normal size.

The items in the list (when it is populated) must be will full path: e.g. C:\blahblah\abcd.xls or without ".xls"




Hope this helps
-bclt
 

You did not answer my question.

Are you writing this in Visual Basic version 5 or 6 or in Excel Visual Basic for Applications???

Skip,

[glasses] [red]Be advised:[/red]When Viscounts were guillotined just as they were disclosing where their jewels were hidden, it shows to go that you should...
Never hatchet your Counts before they chicken! [tongue]
 
Thank you all for your replies, I would like to write this as a stand alone (I have already done something very similar in vba and I am trying VB (6) as an upgrade so to speak).

This could (and probably will be) on various computers and so then would I need to know the path of each excel installation (I thought if I just pointeed to a .xls sheet it would open in association with excel))

 

In the VB editor, Tools/References and set a reference to the Microsoft Excel n.m[/u] Object Library.

Then declare object variables for the Excel Application and the Workbook, Worksheets, Ranges etc.

Check out the CreateObject and GetObject functions. Your Help should have some examples that will be helpful.

Skip,

[glasses] [red]Be advised:[/red]When Viscounts were guillotined just as they were disclosing where their jewels were hidden, it shows to go that you should...
Never hatchet your Counts before they chicken! [tongue]
 
You need the ShellExecute API which will open a spreadsheet (or any other doc) with it's default application. There are several examples in the forum

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first
'If we're supposed to work in Hex, why have we only got A fingers?'
Essex Steam UK for steam enthusiasts
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top