Home Excel Powerpoint Word Outlook Error Codes

VBA Useful Codes

Welcome to the World of VBA
Home > VBAUsefulCodes

Create Text File from VBA Excel

Using the FileSystemObject not only in excel, also we can interact with external applications like notepad. This demo provides a code to dynamically generate a text file in a specified location with some dample data.

Sub Createtextfile()

Dim fso As Object
Set fso = CreateObject("Scripting.FileSystemObject")
Dim oFile As Object
strPath = "D:\test.txt"
Set oFile = fso.Createtextfile(strPath)
oFile.WriteLine "test"
Set fso = Nothing
Set oFile = Nothing

End Sub


Enter your e-mail below and get notified on the latest blog posts.


VBA Outlook KPI Excel Alt+F11 Dashboards Macros Recording Graphs Automation Developer WaterFall Powerpoint Charts Pivot Tables Forecast Charts

Follow Us