Results 1 to 1 of 1

convertion xlsm to pipe delimited file

Threaded View

  1. #1
    Registered User
    Join Date
    11-01-2011
    Location
    Minnesota
    MS-Off Ver
    Office 2010
    Posts
    3

    convertion xlsm to pipe delimited file

    I am using this code to convert a xlsm into a pipe delimited file. That part works for me. But here comes the fun part. Its not exactly in the correct format.

    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("A1"). _
             SpecialCells(xlLastCell)
            lLastRow = rngLastCell.Row
            nLastCol = rngLastCell.Column
            For lCurrRow = 1 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, sRowString & "|"
                Else
                    Print #1, sRowString
                End If
            Next lCurrRow
            Close #1
        End If
    End Sub
    The formatting of the output is what I did not know until I posted the macro.

    So here is the message I got after posting the macro on the boards.

    "The problem may be that the pipedelimited file isn't in the format that suitcase needs it to be.
    It needs to be in the form of (using dark ritual as an example):

    Card|Price|StdDev|Average|High|Low|Change|Raw N
    Dark Ritual (4th)|0.51|0.00|0.51|0.51|0.51|0.00|1
    Dark Ritual (5th)|1.45|0.00|1.45|1.45|1.45|-0.03|1
    Dark Ritual (A)|14.00|3.00|14.00|17.00|11.00|0.00|2
    Dark Ritual (B)|11.00|0.00|11.00|11.00|11.00|0.51|1
    Dark Ritual (IA)|1.03|0.72|1.03|1.75|0.31|0.09|2
    Dark Ritual (MI)|0.94|0.00|0.94|0.94|0.94|0.00|1
    Dark Ritual (MM)|0.50|7.87|6.06|17.19|0.25|-1.36|3
    Dark Ritual (RV)|0.62|0.00|0.62|0.62|0.62|0.18|1
    Dark Ritual (TE)|1.15|0.00|1.15|1.15|1.15|0.00|1
    Dark Ritual (U)|0.50|0.00|0.50|0.50|0.50|-0.25|1
    Dark Ritual (UZ)|0.75|0.00|0.75|0.75|0.75|0.00|1
    I don't know how to write the marcros but take note of the edition and how suitcase recognizes it. The assumption is there needs to be some code that converts it to this exact format and to have place holders where the columns are not used... E.G StdDev, Average, High, Low, Change, Raw N are all not used (I'm assuming here).
    So taking the Tempest Dark ritual as an example, it should take the line from Tcgplayer.xls:

    Dark Ritual	 B	 Instant	 Black	 C	$1.94	$0.99	$0.74	
     Tempest
    and after running macros, spit out:

    Dark Ritual (TE)|.99|0.00|.99|1.94|.74|0.00|1
    StdDev, Change, and Raw N set to default values of 0.00, 0.00, and 1 respectively."

    This is the excel file http://www.mediafire.com/?zmwlnvac4ne4r01

    And this is the output I get when I use the above post.
    http://www.mediafire.com/?8ax56fru5fa450f

    Any help with this would be amazingly helpful.
    Thanks.
    Last edited by pike; 11-01-2011 at 08:07 PM.

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