Consulting

Results 1 to 3 of 3

Thread: Create Text File with FSO and VBA CreateTextFile

  1. #1
    VBAX Visitor
    Joined
    Oct 2018
    Posts
    1
    Location

    Create Text File with FSO and VBA CreateTextFile

    Hi,

    Have a problem with Write data from the HTTP to text file.
    Below part of application in VBA:

    Dim objXMLHTTP, xml
    targetURL = https://cvpp.eviesiejipirkimai.lt/?Q...=1&PageSize=90
    Set xml = CreateObject("Microsoft.XMLHTTP")
    Set fso = CreateObject("Scripting.FileSystemObject")
    xml.Open "GET", targetURL, False
    xml.setRequestHeader "Cache-Control", "no-cache"
    xml.Send
    Set tfile = fso.CreateTextFile("C:\Desktop\failas.asp", True)
    tfile.Write xml.ResponseText   ' Have Run-time error '5': Invalid procedure call or argument
    Set fso = Nothing
    tfile.Close
    Sorry for long "targetURL", just you can try real web site and data.
    After change last parameter "PageSize=80" have a good result for text file "failas.asp" without "Error '5'".

    What I have did in wrong way?


    Best regards,
    Wirgis

  2. #2
    Moderator VBAX Guru Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    4,997
    Location
    Yet again another thread posted to the wrong forum.
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  3. #3
    try:
    im objXMLHTTP, xml
    targetURL = https://cvpp.eviesiejipirkimai.lt/?Q...=1&PageSize=90
    Set xml = CreateObject("Microsoft.XMLHTTP")
    Set fso = CreateObject("Scripting.FileSystemObject")
    xml.Open "GET", targetURL, False
    xml.setRequestHeader "Cache-Control", "no-cache"
    xml.Send
    Set tfile = fso.CreateTextFile(Environ$("UserProfile") & "\Desktop\failas.asp", True)
    tfile.Write xml.ResponseText   ' Have Run-time error '5': Invalid procedure call or argument
    Set fso = Nothing
    tfile.Close

Posting Permissions

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