Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2013, 07:29 AM
Geza59 Geza59 is offline How to add a blank line within an exporting sub? Windows XP How to add a blank line within an exporting sub? Office 2003
Novice
How to add a blank line within an exporting sub?
 
Join Date: May 2012
Location: Budapest, Hungary
Posts: 20
Geza59 is on a distinguished road
Question 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
Also, does someone know of a website with code tutorials related to exporting excel data to text file? This is such an interesting and powerful subject.
Reply With Quote
  #2  
Old 02-13-2013, 06:22 AM
OTPM OTPM is offline How to add a blank line within an exporting sub? Windows 7 32bit How to add a blank line within an exporting sub? Office 2010 32bit
Expert
 
Join Date: Apr 2011
Location: West Midlands
Posts: 981
OTPM is on a distinguished road
Default

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
Reply With Quote
  #3  
Old 02-14-2013, 12:23 AM
macropod's Avatar
macropod macropod is offline How to add a blank line within an exporting sub? Windows 7 64bit How to add a blank line within an exporting sub? Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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]
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to add a blank line within an exporting sub? Line Numbering & Blank Lines Ephasa Word 9 04-30-2020 02:09 PM
How to add a blank line within an exporting sub? 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
How to add a blank line within an exporting sub? 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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:45 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft