PDA

View Full Version : Sleeper: Open txt file on website



Justinlabenne
04-12-2005, 05:51 AM
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

Norie
04-12-2005, 06:19 AM
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.

johnske
04-12-2005, 06:42 AM
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

Justinlabenne
04-12-2005, 01:36 PM
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,