LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 121
Default return filename

You're right about the path.
Was setting path as if on my workstation instead of on the network.
Thanks for jogging my brain awake.


NickHK wrote:

You either need to include the path in the list box entry, or have some way
of determining and setting the path.
You are currently changing the CurDir with
ChDir "C:\TestDir\Matt-House"

which is obviously wrong as you need:
P:\House

Here's one way to get the user to select the folder:
http://vbnet.mvps.org/code/browse/browsefolders.htm

Depending on your version of Excel, it may have a built-in BrowseForFolder
(something like that anyway) method.

NickHK

"Joanne" wrote in message
...
Chip
This works perfectly on my home lap top - but when I transport the code
to my work computer, change the path to reflect the path at work
("P:\House") I get an error saying that the file cannot be found. I have
tried it on several files with the same result. Doing step thru fname
does = the listindex value giving me the filename I requested. Just will
not go to the subdirectory and find the matching filename and open it
up.
Any ideas why it is working on one computer and not on the other?


Private Sub lbVendor_Click()
Dim fname As String
With lbVendor
fname = .List(.ListIndex) 'capture the value of the list index#
selected
End With
ChDir "C:\TestDir\Matt-House"
Workbooks.Open fname
End Sub

Thank you




Chip Pearson wrote:

Joanne,

The ListIndex property returns the 0-based number of the item in the

list.
To get the actual value, use the Value property of

With lblVendor
fname = .List(.ListIndex)
End With







 
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
SaveAs Filename:=filename, FileFormat:=xlCSV Teddy[_3_] Excel Programming 2 May 29th 07 02:34 PM
Converting a Variable Filename to a Constant Filename Magnivy Excel Programming 2 August 15th 06 06:13 PM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
set excel <filename to <filename-date bob engler Excel Programming 2 July 12th 06 08:22 AM
Function to return filepath given full filename Matt Lawson[_3_] Excel Programming 8 March 3rd 04 02:32 AM


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