![]() |
Workbooks.OpenText
I'd like to use Workbooks.OpenText to open a text file in the same folder
as the xl file I'm running it from. At the moment an absolute reference works "C:\...\...\output1.txt.", but the file name on its own doesn't. Workbooks.OpenText FileName:= "output1.txt" Any suggestions ? Thanks |
Workbooks.OpenText
Excel is trying to open the file in the current directory (call CurDir to
get the current directory). If this is the wrong directory then change it using ChDir and ChDrive. Alan "Alistair Eberst" wrote in message ... I'd like to use Workbooks.OpenText to open a text file in the same folder as the xl file I'm running it from. At the moment an absolute reference works "C:\...\...\output1.txt.", but the file name on its own doesn't. Workbooks.OpenText FileName:= "output1.txt" Any suggestions ? Thanks |
Workbooks.OpenText
Dim sPath as String
sPath = ThisWorkbook.Path if Right(sPath,1) < "\" then _ sPath = sPath & "\" Workbooks.OpenText Filename:=sPath & "output1.txt" -- Regards, Tom Ogilvy "Alistair Eberst" wrote in message ... I'd like to use Workbooks.OpenText to open a text file in the same folder as the xl file I'm running it from. At the moment an absolute reference works "C:\...\...\output1.txt.", but the file name on its own doesn't. Workbooks.OpenText FileName:= "output1.txt" Any suggestions ? Thanks |
All times are GMT +1. The time now is 08:17 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com