![]() ![]() ' The number of blank lines to include in the new file ' The text string to write the included lines to We’ll start by defining several variables and give them initial values. ![]() Now, we can read each line in the file but first we need to consider the code we need to discard the blank lines. Dim fso As Scripting.FileSystemObjectįilePath = ActiveWorkbook.path & "filesblanks.txt" ![]() The code for accessing the file system is the sort of procedure you might want to save in a code library for future reference. VBA Macro to Compare Two Files to Determine if They are Identicalįirst, we’ll access the file system object (FSO) and open the file, which we’ve named “blanks.txt”. Then, we’ll write the text string back into a new file. The logic of the code involves reading each line of the file, and saving the line into a text string if it meets our criteria. This article will show you how to remove a set number of blank lines from a text file using some common sense VBA coding. Part of the problem is that you don’t want to remove every blank line otherwise it might upset the formatting of the document. If you’ve ever worked with text files, you’ll know how frustrating it can be to remove empty lines. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |