#1
|
|||
|
|||
How to add a blank line within an exporting sub?
Hi!
Could someone show me how to modify an existing macro that exports some stuff to a text file, so that it will also add a blank line at the end? Here is the sub macro that I want to modify: Code:
Sub CommandButton4_Click() ' This macro exports the vote results to the log file Dim FileName As String ' the file to write to Dim DataRange As Range ' the range containing the data to export Dim Append As Boolean ' whether to append or overwrite existing data Dim SkipEmptyRows As Boolean ' whether to skip empty rows Dim PadRight As Boolean ' whether to pad short fields on the right Dim PadChar As String ' character to use when padding short fields Dim FieldSpecs As String ' the columns and number of characters for export Dim Result As Long ' the result of the export procedure. ' Set up the values to do the export ' CHANGE THESE VALUES AS DESIRED FileName = "D:\ADATA\~Maci\My Files\~Tarsashaz\Forms\LogFile.txt" Set DataRange = Range("D4:Q7") Append = True SkipEmptyRows = True PadRight = True PadChar = Space(1) FieldSpecs = "D,13|E,6|F,6|G,6|H,6|I,6|J,6|K,6|L,6|M,6|N,6|O,6|P,6|Q,5" ' Do the actual export Result = ExportFixedWidth(FileName, DataRange, Append, _ SkipEmptyRows, PadRight, PadChar, FieldSpecs) ' test the result If Result >= 0 Then MsgBox Format(Result, "#,##0") & " records exported to file: " & FileName Else MsgBox "An error occurred exporting the data." End If End Sub |
#2
|
|||
|
|||
Hi
Can you not just change your data range to include a blank row. For example if Q8 sits on a blank row you could include that row in your range. I am not a VBA expert but just thought I would make a suggestion. Tony |
#3
|
||||
|
||||
I assume you have a sub somewhere named 'ExportFixedWidth', but you haven't shown us that. If you're unable to extend the range as Tony suggests, your 'ExportFixedWidth' sub is where the change would need to be made.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Line Numbering & Blank Lines | Ephasa | Word | 9 | 04-30-2020 02:09 PM |
Blank Line Supression | Nibbles | Mail Merge | 4 | 11-21-2012 02:32 AM |
How to Center One Line Vertically on Blank Page | SQLUSA | Word | 1 | 08-29-2012 08:14 PM |
Need help on Macro 03- Find text - if text is blank then remove line | simpleonline1234 | Word VBA | 1 | 02-25-2011 02:28 AM |
When i clicked on a file, it showed up blank.(LIFE ON LINE)! | angelo1405 | Word | 0 | 03-17-2008 04:47 PM |