Results 1 to 9 of 9

Output Text file is empty while exporting from excel table using macros

Threaded View

arry0207 Output Text file is empty... 07-08-2013, 07:24 AM
JosephP Re: Output Text file is empty... 07-08-2013, 07:29 AM
arry0207 Re: Output Text file is empty... 07-08-2013, 07:43 AM
arry0207 Re: Output Text file is empty... 07-08-2013, 07:40 AM
JosephP Re: Output Text file is empty... 07-08-2013, 07:43 AM
arry0207 Re: Output Text file is empty... 07-08-2013, 07:48 AM
JosephP Re: Output Text file is empty... 07-08-2013, 08:00 AM
arry0207 Re: Output Text file is empty... 07-08-2013, 08:06 AM
JosephP Re: Output Text file is empty... 07-08-2013, 08:08 AM
  1. #1
    Registered User
    Join Date
    07-05-2013
    Location
    India
    MS-Off Ver
    Excel 2007
    Posts
    5

    Output Text file is empty while exporting from excel table using macros

    Hi There,
    I am not getting any data in generated text file using macros.
    Anyone please help .

    Here is the Code

    Sub SaveAsPipeDelimited()
        Dim vFileName As Variant
        Dim rngLastCell As Range
        Dim lLastRow As Long
        Dim nLastCol As Integer
        Dim lCurrRow As Long
        Dim nCurrCol As Integer
        Dim sRowString As String
          
        vFileName = Application.GetSaveAsFilename(filefilter:= _
         "Text Files (*.txt), .txt")
        If vFileName <> False Then
            Open vFileName For Output As #1
            Set rngLastCell = ActiveSheet.Range("Table1"). _
             SpecialCells(xlLastCell)
             lLastRow = rngLastCell.End(xlUp).Row
             nLastCol = rngLastCell.Column
    
                For lCurrRow = 2 To lLastRow
                sRowString = ActiveSheet.Cells(lCurrRow, 1).Formula
                For nCurrCol = 2 To nLastCol
                   sRowString = sRowString & "|" & ActiveSheet _
                    .Cells(lCurrRow, nCurrCol).Formula
                Next nCurrCol
                If Len(sRowString) = nLastCol - 1 Then
                    '/ print blank line only
                    Print #1,
                Else
                    Print #1, sRowString
                End If
            Next lCurrRow
            Close #1
        End If
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1