Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,588
Default 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



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2
Default 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
:


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
ON OPEN VBA Code input incorrectly now excel sheet wont open mmartin New Users to Excel 1 February 16th 11 11:33 PM
Macro to automatically open a website or send an e-mail in excel Byron Excel Discussion (Misc queries) 3 April 7th 06 09:05 AM
want to download csv file from website and need to open in Excel. Jeff Excel Discussion (Misc queries) 2 January 17th 06 05:35 PM
Is it possible to link spreadsheet to website for input vanbass Excel Discussion (Misc queries) 0 October 20th 05 07:26 AM
Can't open XL file on website in IE6 edger Excel Discussion (Misc queries) 0 December 20th 04 09:59 PM


All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"