ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   User defined file name in an OpenText File command (https://www.excelbanter.com/excel-programming/300775-user-defined-file-name-opentext-file-command.html)

surveyorinva

User defined file name in an OpenText File command
 
using the OpenText File command, is there a way for the user using th
macro define the path & file name rather then it defaulting to the fil
defined in the code.

Here is the original code: Right now I have to have the user befor
using the Excel file to define their data in this data.txt file. Whic
is an extra step that if at all possible needs to be stream lined.

Workbooks.OpenText FileName:="C:\Cutsheets\data.txt"
Origin:=xlWindows, _StartRow:=1, DataType:=xlFixedWidth
FieldInfo:=Array(0, 1)

I appreciate any help in this.
Thanks,
Chri

--
Message posted from http://www.ExcelForum.com


Bob Phillips[_6_]

User defined file name in an OpenText File command
 
You could use INputBox to ask the user for input, or even use the
GetOpenFileName method to allo0w the user to browse folders for a file. The
latter just returns the file name, it doesn't open it.

--

HTH

Bob Phillips
... looking out across Poole Harbour to the Purbecks
(remove nothere from the email address if mailing direct)

"surveyorinva " wrote in
message ...
using the OpenText File command, is there a way for the user using the
macro define the path & file name rather then it defaulting to the file
defined in the code.

Here is the original code: Right now I have to have the user before
using the Excel file to define their data in this data.txt file. Which
is an extra step that if at all possible needs to be stream lined.

Workbooks.OpenText FileName:="C:\Cutsheets\data.txt",
Origin:=xlWindows, _StartRow:=1, DataType:=xlFixedWidth,
FieldInfo:=Array(0, 1)

I appreciate any help in this.
Thanks,
Chris


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 01:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com