Retrieving File Name from Text file

J

Jeff Armstrong

I am trying to store the file name of a text file that I
open. The following code is what I am trying to use but
when I watch the variable for TrunkName it always ends up
being "". Can someone tell me what I am doing wrong?

**********************************************************
Public Sub DoTheImport()
Dim FName As Variant
Dim Sep As String
Dim TrunkName as String

ImportFileNames
daRows = Application.CountA(ActiveSheet.Range"A:A"))
For zZ = 1 To daRows 'Set up loop
Open Cells(zZ, 1) For Input Access Read As #1
TrunkName = Application.FileSearch.Filename
Sep = " "
ImportTextFile CStr(FName), Sep
Close #1
Next 'Close the file
End Sub
**********************************************************

Thanks,
Jeff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top