Dear all,
could you show me plz how to create a batch file can
export data from excel to text file and save this text file in (C:\) drive
plz i need your help
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Here is a short macro that creates a text file from Excel data.
Sub Export() Dim objFs As Object Dim objText As Object Dim strData As String Dim n As Integer Set objFs = CreateObject("Scripting.FileSystemObject") 'create the text file with Path & text filename Set objText = objFs.CreateTextFile("C:\MyExcelData.txt", 1) 'create a string from the data For n = 0 To 20 strData = strData & ActiveSheet.Range("B2").Offset(n, 0).Text & vbCrLf Next n 'write the string to the text file objText.WriteLine (strData) 'close the text file objText.Close 'remove the file system object Set objFs = Nothing End SubIt includes a loop to collect data from cells in a column starting at cell B2, using an offset to move through a range.
There are lots of ways to collect the data, so you can modify the data capture to suit your needs and still use the basic file system.
Hope this helps.
Regards