How to export data from excel into multiple notepad file?

Example ;



In the above table, I have 4 rows. Is it possible to export details of Emp No 12 into a single notepad file, Emp No 13 into a single notepad file?

Answer
Answer

Example ;



In the above table, I have 4 rows. Is it possible to export details of Emp No 12 into a single notepad file, Emp No 13 into a single notepad file?


You could use the Excel file as the data source for a mail merge in Word to create a Word document that contains the data for each Emp in a separate Section in the document.

Then you could use a macro with the following code to split that document into individual .txt files that could be opened in Notepad

Sub splitter()
' splitter Macro
' Macro created by Doug Robbins to save each letter created by a mailmerge
' as a separate file, retaining the header and footer information.
Dim i As Long, Source As Document, Target As Document, Letter As Range
Set Source = ActiveDocument
For i = 1 To Source.Sections.Count
    Set Letter = Source.Sections(i).Range
    Set Target = Documents.Add
    Target.Range = Letter
    Target.Sections(2).PageSetup.SectionStart = wdSectionContinuous
    Target.SaveAs filename:="Letter" & i & ".txt", FileFormat:=wdFormatDOSText
    Target.Close
Next i
End Sub

Notepad itself does not have the mail merge capability.

Hope this helps,
Doug Robbins - MVP Office Apps & Services (Word)
dougrobbinsmvp@gmail.com
It's time to replace ‘Diversity, Equity & Inclusion’ with ‘Excellence, Opportunity & Civility’ - V Ramaswamy

Was this reply helpful?

Sorry this didn't help.

Great! Thanks for your feedback.

How satisfied are you with this reply?

Thanks for your feedback, it helps us improve the site.

How satisfied are you with this reply?

Thanks for your feedback.

 
 

Question Info


Last updated September 30, 2021 Views 1,229 Applies to: