Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / General 1 / February 2005

Tip: Looking for answers? Try searching our database.

write to text file

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
rcmail14872@yahoo.com - 19 Feb 2005 21:57 GMT
The following code will "append" text to the END of the text file.  How
can I add text to the beginning of a text file?

Dim fno As Integer

fno = FreeFile
Open "test.txt" For Append As #fno
Print #fno, "Hello World"
Close #fno

fno = FreeFile
Open "test.txt" For Append As #fno
Print #fno, "Hello World2"
Close #fno
Tony Toews - 19 Feb 2005 22:42 GMT
>The following code will "append" text to the END of the text file.  How
>can I add text to the beginning of a text file?

To the beginning and leave the rest of the file intact?    I think you'd have to
create a new file write the new data and then copy the data from the old file.

Tony
--
Tony Toews, Microsoft Access MVP
  Please respond only in the newsgroups so that others can
read the entire thread of messages.
  Microsoft Access Links, Hints, Tips & Accounting Systems at
http://www.granite.ab.ca/accsmstr.htm
rcmail14872@yahoo.com - 19 Feb 2005 22:50 GMT
The text to be inserted at the beginning of the file is static text so
the "beggining" file (let's call it FileA) could already exist.   If I
copy FileB to FileA will it insert all the text from FileB to the end
of FileA?
pietlinden@hotmail.com - 19 Feb 2005 23:08 GMT
> The text to be inserted at the beginning of the file is static text so
> the "beggining" file (let's call it FileA) could already exist.   If I
> copy FileB to FileA will it insert all the text from FileB to the end
> of FileA?

AFAIK, you can only insert at the end.  So create a new text file, add
the header stuff, then copy the data from the old file.  Save the new
file, delete the old one, and rename the new one.  Just use the Name
function.
 
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.