Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Copy/ move selected data from workbooks to seperate worksheets or workbooks | Excel Worksheet Functions | |||
Display 2 formulas from source workbooks to destination workbooks | Excel Discussion (Misc queries) | |||
Using Workbooks.OpenText to read a tab-delimited file into a worksheet | Excel Programming | |||
How do I unprotect cells when using OpenText function? | Excel Programming | |||
OpenText bug ? | Excel Programming |