Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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




  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default 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






  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default 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






Reply
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
Copy/ move selected data from workbooks to seperate worksheets or workbooks Positive Excel Worksheet Functions 1 August 30th 07 04:54 PM
Display 2 formulas from source workbooks to destination workbooks Excel_seek_help Excel Discussion (Misc queries) 4 April 27th 06 08:13 PM
Using Workbooks.OpenText to read a tab-delimited file into a worksheet Dan E[_2_] Excel Programming 0 August 19th 03 08:02 PM
How do I unprotect cells when using OpenText function? Scott Lyon Excel Programming 1 August 18th 03 10:07 PM
OpenText bug ? Orlando Magalhães Filho Excel Programming 0 August 1st 03 04:14 AM


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