Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Using FileOpen

Using FileOpen

I am trying to
1. Get the file path from an excel sheet.
2. Open the text file for input.

Dim strFILENAME As String
strFILENAME = Sheet1.Range("E1").Value
FileOpen(1, "strFILENAME", OpenMode.Input)
...
blah = LineInput(1)


When compiling, I seem to have a syntax error on FileOpen an
LineInput. Any ideas of why this might be a problem?

Also what is the difference between using FileOpen and
Open strFILENAME For Input As #1 ? and FileClose and Close #1? If I d
the latter choices for both questions, am I able to use LineInput?

Thanks :

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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Using FileOpen

Tippy,

Try something like the following:

Dim S As String
Dim FName As String
Dim FNum As Integer

FName = "C:\Temp\Test.txt"
FNum = FreeFile
Open FName For Input Access Read As #FNum
Do Until EOF(FNum)
Line Input #FNum, S
Debug.Print S
Loop
Close #FNum

--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com




"Tippy " wrote in message
...
Using FileOpen

I am trying to
1. Get the file path from an excel sheet.
2. Open the text file for input.

Dim strFILENAME As String
strFILENAME = Sheet1.Range("E1").Value
FileOpen(1, "strFILENAME", OpenMode.Input)
..
blah = LineInput(1)


When compiling, I seem to have a syntax error on FileOpen and
LineInput. Any ideas of why this might be a problem?

Also what is the difference between using FileOpen and
Open strFILENAME For Input As #1 ? and FileClose and Close #1?

If I do
the latter choices for both questions, am I able to use

LineInput?

Thanks :)


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



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
Selecting a file path in Excel VBA using FileOpen dialog John Robinson Excel Programming 1 November 1st 03 09:59 AM


All times are GMT +1. The time now is 08:28 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"