Open a Binary File for Appending

Posted on 2005-04-26
Last Modified: 2009-11-08
The statement "Open filename For Append As #1" opens an ASCII file for appending.  The statement "Open filename For Binary Access Write As #1" opens a BINARY file for writing.  Is there a statement that opens a binary file for APPENDING?  The following statement does not work:  Open filename For Binary Access Append As #1".
Question by:richelieu7777
    LVL 85

    Accepted Solution

    Just open it and binary mode and move the file pointer to the end...thus making it ready for appending:

    Private Sub Command1_Click()
        Dim FileName As String
        FileName = "c:\someFile.txt"
        Open FileName For Binary Access Write As #1
        Seek #1, LOF(1) + 1 ' move the file pointer to the end...thus appending!
        Put #1, , "something to be appended..."
        Close #1
    End Sub
    LVL 4

    Expert Comment

    You made an assumption that only text files can be opened for Append mode, not i :-)

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now