ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Opening a file using VBA (https://www.excelbanter.com/excel-programming/304249-opening-file-using-vba.html)

Shabbir

Opening a file using VBA
 
Hi,

Im trying to write a piece of code which will open a txt file. the following code works for the first part of what i am trying to do:

Workbooks.OpenText Filename:= "C:\VisionMate Database\Rack_1_20040715-105339_.txt"

The file location can vary and the actual path to the correct file is stored in cell A1 in sheet1 in the workbook. How do i replace the filename in the code above to read the file path that is stored in cell A1.

Anyhelp will be greatly appreciated!

Thank you

Frank Kabel

Opening a file using VBA
 
Hi
try
....
dim fname
dim fpath
fname = activesheet.range("A1").value
fpath = "C:\VisionMate Database\"
fnane = fname & ".xls"
workbooks.open fpath & fname

-----Original Message-----
Hi,

Im trying to write a piece of code which will open a txt

file. the following code works for the first part of what
i am trying to do:

Workbooks.OpenText Filename:= "C:\VisionMate

Database\Rack_1_20040715-105339_.txt"

The file location can vary and the actual path to the

correct file is stored in cell A1 in sheet1 in the
workbook. How do i replace the filename in the code above
to read the file path that is stored in cell A1.

Anyhelp will be greatly appreciated!

Thank you
.



All times are GMT +1. The time now is 12:23 PM.

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