Debug.Print to Text File

Posted on 2004-11-09
Last Modified: 2010-05-18
What is the best way in which to send a Debug.Print to a text file?
Question by:eciabattari
    LVL 5

    Expert Comment

    Why use Debug.Print?

    Instead create a text file using ...

    Open "MyFile.txt" FOR Output AS #1

    Print #1, strTheDebugPrintStatement

    Close #1

    LVL 5

    Accepted Solution

    Actually, I should have said you should use FreeFile() to get the filehandle and assign it to a variable (global if necessary)

    You also want to Open the file once - not for each "Debug.Print" you want.  Each call to Open removes the previous file unless you start using For Append instead of For Output


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Introduction In a recent article ( for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
    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…

    794 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

    15 Experts available now in Live!

    Get 1:1 Help Now