• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

VBA to insert data into notepad without extra double quotes

saidhruv

Member
Dear All,

Can you please help me with a VBA to export data into notepad file. I am facing three problems:
Problem1: Certain lines when exported to notepad file contain DOUBLE QUOTEs at start & end of the line. These extra double quotes need not be inserted into notepad. Please note that data may contain actual double quote, hence a substitue logic may not work here.
Problem2: After last data point the notepad will take an extra blank line. This extra line or tab is not required.
Problem3: Text file name should be same as excel file name and should be saved at same path where excel is available.0

Sharing sample of excel file. Also sharing text file which i am currently getting, which is erroneous. Also sharing expected output.

regards
dhruv
 

Attachments

  • A1.xlsx
    8.4 KB · Views: 2
  • A1_erroneous.txt
    451 bytes · Views: 3
  • A1_expected.txt
    445 bytes · Views: 3
Hi,

according to your attachment try next demonstration !​
Code:
Sub Demo()
    Open Left(ActiveWorkbook.FullName, InStrRev(ActiveWorkbook.FullName, ".")) & "txt" For Output As #1
    Print #1, Join(Application.Transpose(ActiveSheet.UsedRange.Columns(1).Value), vbCrLf);
    Close #1
End Sub
Do you like it ? So thanks to click on bottom right Like !
 
Dear Marc L, this code is super perfect. Thanks a lot.. God Bless You Marc L. with super Health & super Happiness!
 
Thanks and enjoy it !

It works only for data of first column used according to your attachment …
Dear Marc L - can you pls share a code that can insert in Notepad++ instead of Notepad? Same logic, but saving in Notepad++
 
As you very did not understand :
my code does not save for Notepad
but for a file format and here as a text file.

Notepad & Nopepad++ are both text files editor :
so whatever editor you use, no needs to mod my code !
 
Back
Top