Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / November 2005

Tip: Looking for answers? Try searching our database.

File Location

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Greg - 01 Nov 2005 13:45 GMT
Word VBA Help gives the following example for the EOF function.

Sub Test()
Dim InputData
Open "MYFILE" For Input As #1    ' Open file for input.
Do While Not EOF(1)    ' Check for end of file.
   Line Input #1, InputData    ' Read line of data.
   Debug.Print InputData    ' Print to the Immediate window.
Loop
Close #1    ' Close file.
End Sub

When I try to run this test, I get an error file not found.  How do I
indentify the location of "MYFILE" in the code above?  Thanks.
Jonathan West - 01 Nov 2005 13:53 GMT
Hi Greg,

what is happening here is that the code is looking for a file named "MYFILE"
in the current folder, wherever that happens to be

The current folder is returned by the CurDir function.

Better would be to include the full filepath in the filename when using the
Open command. That avoids any possibility of confusion

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

> Word VBA Help gives the following example for the EOF function.
>
[quoted text clipped - 10 lines]
> When I try to run this test, I get an error file not found.  How do I
> indentify the location of "MYFILE" in the code above?  Thanks.
Greg - 01 Nov 2005 14:18 GMT
Thanks Jonathan.  With people like you around to help with the help
files even a visually challenged squirrel can find a nut.

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.