Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Posts
    29

    Red face Unanswered: responseText in xmlHttp - Weird

    Can anyone explain why code that has been working for the last 3 months suddenly decides that it is an "Invalid Procedure Call or Argument"?

    The following code gets a text file from URL and saves it to the local drive and then transfers it to an Access table:

    CalData.Open "GET", "http://www.webadress.com/exportfile?fn=Data", False
    CalData.send (aVar)


    Set fs = CreateObject("Scripting.filesystemobject")
    fs.CreateTextFile "c:\CalData.txt"
    Set f = fs.GetFile("C:\CalData.txt")
    Set ts = f.OpenAsTextStream(2, TristateUseDefault)
    ts.Write CalData.responseText

    ts.Close

    DoCmd.TransferText acImportDelim, "GetURLDataFini", "tbl_CalData_Import", "C:\CalData.txt"
    On the line:
    ts.Write CalData.responseText
    is where the error occurs.

    I am completely at a loss on this. As I said, it worked perfectly for 3 months. I have checked to see if something changed prior to this executing that may have caused the issue, but I see nothing.

    Any help would be greatly appreciated.

    Ab

  2. #2
    Join Date
    Sep 2003
    Posts
    29

    Re: responseText in xmlHttp - Weird

    Aha... Well the actual problem is coming from the ts.write part of the code and NOT the responseText portion. The response text can be passed to a variable so it IS getting the data. I just need it to write to a text file now.

    Any other ideas??




    Originally posted by abboabbo
    Can anyone explain why code that has been working for the last 3 months suddenly decides that it is an "Invalid Procedure Call or Argument"?

    The following code gets a text file from URL and saves it to the local drive and then transfers it to an Access table:

    CalData.Open "GET", "http://www.webadress.com/exportfile?fn=Data", False
    CalData.send (aVar)


    Set fs = CreateObject("Scripting.filesystemobject")
    fs.CreateTextFile "c:\CalData.txt"
    Set f = fs.GetFile("C:\CalData.txt")
    Set ts = f.OpenAsTextStream(2, TristateUseDefault)
    ts.Write CalData.responseText

    ts.Close

    DoCmd.TransferText acImportDelim, "GetURLDataFini", "tbl_CalData_Import", "C:\CalData.txt"
    On the line:
    ts.Write CalData.responseText
    is where the error occurs.

    I am completely at a loss on this. As I said, it worked perfectly for 3 months. I have checked to see if something changed prior to this executing that may have caused the issue, but I see nothing.

    Any help would be greatly appreciated.

    Ab

  3. #3
    Join Date
    Sep 2003
    Posts
    29

    Re: responseText in xmlHttp - Weird

    OK, well, here is what I have done to get around this in case anyone runs in to this same issue. It appears to be working every bit as well as what I was doing.

    I simply added the standard file open/append/close as #1 technique. I did not think this would keep the file in tab delimited format, but it appears to import as well as the other method was working (until yesterday). Here are the changes to the code:

    Dim CalData As XMLHTTP
    Set CalData = CreateObject("Microsoft.xmlhttp")

    CalData.Open "GET", "http://www.webadress.com/exportfile?fn=Data", False
    CalData.send (aVar)


    Set fs = CreateObject("Scripting.filesystemobject")
    fs.CreateTextFile "c:\CalData.txt"
    Set f = fs.GetFile("C:\CalData.txt")
    Set ts = f.OpenAsTextStream(2, TristateUseDefault)
    VariableX = CalData.responseText
    ts.close
    Open "C:\CalData.txt" For Append As #1
    Write #1, VariableX
    Close #1

    DoCmd.TransferText acImportDelim, "GetURLDataFini", "tbl_CalData_Import", "C:\CalData.txt"
    fs.DeleteFile "C:\CalData.txt"



    Originally posted by abboabbo
    Can anyone explain why code that has been working for the last 3 months suddenly decides that it is an "Invalid Procedure Call or Argument"?

    The following code gets a text file from URL and saves it to the local drive and then transfers it to an Access table:

    CalData.Open "GET", "http://www.webadress.com/exportfile?fn=Data", False
    CalData.send (aVar)


    Set fs = CreateObject("Scripting.filesystemobject")
    fs.CreateTextFile "c:\CalData.txt"
    Set f = fs.GetFile("C:\CalData.txt")
    Set ts = f.OpenAsTextStream(2, TristateUseDefault)
    ts.Write CalData.responseText

    ts.Close

    DoCmd.TransferText acImportDelim, "GetURLDataFini", "tbl_CalData_Import", "C:\CalData.txt"
    On the line:
    ts.Write CalData.responseText
    is where the error occurs.

    I am completely at a loss on this. As I said, it worked perfectly for 3 months. I have checked to see if something changed prior to this executing that may have caused the issue, but I see nothing.

    Any help would be greatly appreciated.

    Ab

Posting Permissions

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