LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Excel cannot find file error

without knowing more

Public Sub lbVendor_Click()
Dim fname As String
With lbVendor
fname = .List(.ListIndex) ' capture the value of the list index#
selected
End with
Debug.Print fname
if obHouse then
spath = "C:\Pricing\House\"
elseif obDan then
spath - "C:\Pricing\Dan\"
elseif obSue then
spath = "C:\Pricing\Sue\"
elseif etc then
End if
Workbooks.Open sPath & fname & ".xls"
fname = "" 'clears fname in case they choose another opt button
Debug.Print fname
End Sub

--
Regards,
Tom Ogilvy

"Joanne" wrote:

Tom
That did the trick for me - works great

but now I have the problem of telling vba what sub-directory to goto to
get the correct workbook. I don't know how to pass the path to the
lbVendor.click event. It is based on which (of 5) option buttons is
clicked to fill the list box - obHouse needs to look in
C:\pricing\house, whereas obDan needs to look in C:\Pricing\Dan etc etc.

I know I can't change the sub-directory in the fill list box routine
because fname has not gotten it's value yet.

Would you be kind enough to help me along a bit more? I sure appreciate
your time and efforts. Thanks a million

Here is the code again

' Fill the list box
Private Sub obHouse_Click()
Dim SrcData As Range
Dim cCell As Range
Set SrcData = Range("rngHouse2")
With lbVendor
.Clear
For Each cCell In SrcData.Cells
.AddItem cCell.Value
Next cCell
End With
End Sub

' Open the workbook
Public Sub lbVendor_Click()
Dim fname As String
With lbVendor
fname = .List(.ListIndex) ' capture the value of the list index#
selected
Debug.Print fname
End With
Workbooks.Open "C:\Pricing\House\" & fname & ".xls"
fname = "" 'clears fname in case they choose another opt button
Debug.Print fname
End Sub



 
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
Excel 2007 - error saving file & error loading dll TinaF Excel Discussion (Misc queries) 0 July 1st 09 01:49 PM
error - unreadable content in pivot table file - how do I find it BarbC Excel Worksheet Functions 1 March 30th 09 06:09 PM
Cannot find file - code error keri Excel Programming 2 June 30th 07 03:21 PM
Automation Error: The system cannot find file specified Shilpa[_2_] Excel Programming 3 August 25th 06 09:05 AM
How do I find a file/spreadsheet that Excel says is Already open but I can't find it? nwtrader8 Excel Discussion (Misc queries) 5 June 21st 05 02:16 PM


All times are GMT +1. The time now is 11:48 AM.

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"