Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167

    Unanswered: 'WriteLine' Function Problems With Large String

    I have a code I wrote that is supposed to write a tab-delimited text string to a text file. It worked flawlessly when there were only 2 rows (header and one order record) but when there are many orders and I try to run I get "Run-time error '5' ". The help says it is probably because the string is outside the range allowed by the WriteLine function.

    Does anyone have any ideas for how to fix this problem? Is there a different function I should use or should I do something differently with this function. Please Let me know what I am doing wrong and if possible include a sample code if you think you might have a solution.

    This would solve so many problems if I could get it to work. Thanks in advance! Joshua


    Code:
    'THIS GETS THE RESPONSE FROM AMAZON
        Dim Response As String
        Response = API.ResponseText
    
    'THIS SHOULD WRITE THE RESPONSE TO A TEXT FILE
        Set fs = CreateObject("Scripting.FileSystemObject")
            Set a = fs.CreateTextFile("H:\AmazonTempText1.txt", True) 'True for overwrite
            a.WriteLine (Response) 'Debug goes to this line, file is created but empty
            a.Close

  2. #2
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    Use the good old BASIC way:

    Code:
        Dim intHandle as integer
        Dim Response As String
    
        Response = API.ResponseText
        intHandle = FreeFile
        Open "H:\AmazonTempText1.txt" For Output as #intHandle
        Print #intHandle, Response
        Close #intHandle
    Have a nice day!

  3. #3
    Join Date
    Jan 2009
    Location
    Ohio, United States
    Posts
    167
    Did you ever know that you're my hero! Thanks!

    Joshua

  4. #4
    Join Date
    Mar 2009
    Posts
    5,442
    Provided Answers: 14
    You're welcome.

Posting Permissions

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