Consulting

Results 1 to 4 of 4

Thread: Sleeper: Open txt file on website

  1. #1
    VBAX Mentor Justinlabenne's Avatar
    Joined
    Jul 2004
    Location
    Clyde, Ohio
    Posts
    408
    Location

    Sleeper: Open txt file on website

    From the kb here, I learned how to open xl workbooks on a website for excel, but I am running into trouble opening and writing to a text file on a website

    I just want to open it, write to it, close it, part of an error handling system.
    The code below is practice stuff, but it gets debugged at the file name, not sure how to open it as a text file, I can get it to open using Workbooks.Open, but it opens as read only, and in Excel obviously. Any ideas, or is this not a possible route, tried changing the append #'s, plus .txt, .log, etc... for the extension,

    The website in the code works and the text file is there, in the location if anyone wants to trial it out and see what they come up with. Thanks,


    Sub PracticeWrite()
    '   Log info into txt file on a website
        Dim UName$, xlVersion$, OSVersion$
        Dim WhatTime$, sLogText$, strPath$
    UName = Application.USERNAME
        xlVersion = "Excel version " & Application.Version
        OSVersion = "Running " & Application.OperatingSystem
        WhatTime = Format(Now(), "mm/dd/yy hh:mm:ss")
    sLogText = UName & " " & xlVersion & " " & OSVersion & " " & WhatTime
    strPath = "http://www.jlxl.net/ErrDownload.txt"
    Open strPath For Append As #1
        Print #1, sLogText
        Close #1
    End Sub

  2. #2
    VBAX Master Norie's Avatar
    Joined
    Jan 2005
    Location
    Stirling, Scotland
    Posts
    1,831
    Location
    I'm pretty sure you can't use Open for a web page, as far as I know it's for files on a drive.

  3. #3
    Administrator
    Chat VP
    VBAX Guru johnske's Avatar
    Joined
    Jul 2004
    Location
    Townsville, Australia
    Posts
    2,872
    Location
    Hi Justin,

    Your code gave me errors, this got me there:

    Sub OpenWebPage()
    On Error GoTo 1
    ActiveWorkbook.FollowHyperlink "http://www.jlxl.net/ErrDownload.txt", NewWindow:=True
    Exit Sub
    1: MsgBox Err.Description
    End Sub
    But all I found there was a blank web page - no text doc. I think you'll need to go to the site and get the path to the actual text doc itself and put that path in your url first.


    Regards,
    John
    You know you're really in trouble when the light at the end of the tunnel turns out to be the headlight of a train hurtling towards you

    The major part of getting the right answer lies in asking the right question...


    Made your code more readable, use VBA tags (this automatically inserts [vba] at the start of your code, and [/vba ] at the end of your code) | Help those helping you by marking your thread solved when it is.

  4. #4
    VBAX Mentor Justinlabenne's Avatar
    Joined
    Jul 2004
    Location
    Clyde, Ohio
    Posts
    408
    Location
    The text doc is definetly there, it opens as a web page with the follow hyperlink code, I added some text to it, to make sure I wasn't crazy, tried it again and it opened the ErrDownload.txt file as a webpage. Weird.

    This is just a crazy idea that I came up with, if it's not possible, or seem's too improbable to be reliable, I won't be disappointed. Just wanted to try and see if there is a method to do this, thanks for your help Norie and johnske. I will post back if I find something, please post if you have any more ideas,

    thanks again,

Posting Permissions

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