[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Append to beginning of text file instead of bottom using .vbs

Posted on 2009-04-20
2
Medium Priority
?
231 Views
Last Modified: 2013-12-26
I'm trying to append to the top of a text file rather then the bottom. How can I do this?
This code writes to the bottom rather then the top.
 
Set objFile1 = objFSO.OpenTextFile("C:\offline.txt", 8)
objFile1.Write VbCrLf & strcomputer

Open in new window

0
Comment
Question by:Darkejo1
2 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 2000 total points
ID: 24187143
Dim objFSO, objFileIn, objFileOut, Content

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFileIn = objFSO.OpenTextFile("C:\offline.txt")
Content = objFileIn.ReadAll
objFileIn.Close
Set objFileOut = objFSO.CreateTextFile("C:\offline.txt", True)
With objFileOut
    .WriteLine vbCrLf & strcomputer
    .Write Content
    .Close
End With

Set objFileIn = Nothing
Set objFileOut = Nothing
Set objFSO = Nothing
0
 

Author Closing Comment

by:Darkejo1
ID: 31572362
Thanks!!!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question