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

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
opening a file in Excel starts application but dose not open file Bob Shelton Excel Discussion (Misc queries) 1 July 2nd 08 07:51 PM
Opening file in Excel 2003 opens multipule instances of same file Ed_B Excel Discussion (Misc queries) 1 June 21st 07 07:10 PM
File:1 and File:2 -- Double Files when Opening One File dallin Excel Discussion (Misc queries) 1 January 25th 07 02:53 AM
opening an excel file opens a duplicate file of the same file skm Excel Discussion (Misc queries) 1 December 7th 05 05:52 PM
"Unable to read file" error message when opening a Excel file that contains a PivotTable report. Tim Marsden Charts and Charting in Excel 2 October 15th 05 02:10 PM


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