ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open (website) for Input? (https://www.excelbanter.com/excel-programming/358980-open-website-input.html)

Joey Lichtenstein[_3_]

Open (website) for Input?
 

I know how to do the basic:

open "c:\file.txt" for Input As #1

is it possible to open a web site for text input, and read the html code
as text into VBA? What would the format for the filename be?

Thanks so much in advance!

Joey


Tim Williams

Open (website) for Input?
 
Function GetSource(sURL) As String


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


onerror goto haveError

xmlhttp.Open "GET", sURL, False
xmlhttp.send
GetSource = xmlhttp.responseText
Exit Function
haveError:
GetSource = "Error: " & Err.Description
End Function


Sub test()
MsgBox GetSource("http://www.google.com")
End Sub


Tim



"Joey Lichtenstein" wrote in message
...

I know how to do the basic:

open "c:\file.txt" for Input As #1

is it possible to open a web site for text input, and read the html code
as text into VBA? What would the format for the filename be?

Thanks so much in advance!

Joey




Joey Lichtenstein[_3_]

Open (website) for Input?
 
Thanks Tim!

This Works PERFECT!!!!

Tim Williams <timjwilliams at gmail dot com wrote:


: Function GetSource(sURL) As String


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


: onerror goto haveError

: xmlhttp.Open "GET", sURL, False
: xmlhttp.send
: GetSource = xmlhttp.responseText
: Exit Function
: haveError:
: GetSource = "Error: " & Err.Description
: End Function


: Sub test()
: MsgBox GetSource("http://www.google.com")
: End Sub


: Tim



: "Joey Lichtenstein" wrote in message
: ...
:
: I know how to do the basic:
:
: open "c:\file.txt" for Input As #1
:
: is it possible to open a web site for text input, and read the html code
: as text into VBA? What would the format for the filename be?
:
: Thanks so much in advance!
:
: Joey
:




All times are GMT +1. The time now is 12:09 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com