MaK
7/19/2008 10:53:00 AM
Hi all,
Pls find the code:
Const INTERNET_OPEN_TYPE_DIRECT = 1
Const INTERNET_OPEN_TYPE_PROXY = 3
Const INTERNET_FLAG_RELOAD = &H80000000
Private Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA"
(ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As
String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As
Long) As Integer
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As
Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long,
lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetOpenUrl Lib "wininet" Alias
"InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String,
ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As
Long, ByVal dwContext As Long) As Long
Private Declare Function InternetAttemptConnect Lib "wininet" (ByVal
dwReserved As Long) As Long
Sub Fetch()
Dim tTxt As String
tTxt = DownloadPage(Range("URL"))
End Sub
Function DownloadPage(sURL As String, Optional Length As Long) As String
Dim hOpen As Long, hFile As Long, sBuffer As String, Ret As Long
If Length = 0 Then Length = 10000
sBuffer = Space(Length)
hOpen = InternetOpen("", INTERNET_OPEN_TYPE_DIRECT, vbNullString,
vbNullString, 0)
hFile = InternetOpenUrl(hOpen, sURL, "", 0, INTERNET_FLAG_RELOAD, ByVal
0&)
InternetReadFile hFile, sBuffer, Length, Ret
InternetCloseHandle hFile
InternetCloseHandle hOpen
DownloadPage = Left$(sBuffer, Ret)
End Function
"Don Guillett" wrote:
> The archives would appreciate your final solution to be posted
>
> --
> Don Guillett
> Microsoft MVP Excel
> SalesAid Software
> dguillett1@austin.rr.com
> "Mak" <Mak@discussions.microsoft.com> wrote in message
> news:23D6D515-A8AB-408E-88D5-83E44F883696@microsoft.com...
> > Don,
> > I have made use of Windows API and it works now. Thanks for your help
> > anyway.
> > Mak.
> >
> > "Don Guillett" wrote:
> >
> >> What you want is easy to do. Post your code and/or send your workbook to
> >> my
> >> address below.
> >>
> >> --
> >> Don Guillett
> >> Microsoft MVP Excel
> >> SalesAid Software
> >> dguillett1@austin.rr.com
> >> "Mak" <Mak@discussions.microsoft.com> wrote in message
> >> news:F076D4BF-F0E6-45CE-8F56-B9D09DC1F335@microsoft.com...
> >> >I have downloaded some files, for those VBA that I can view, they are
> >> >using
> >> > QueryTable with Destination = a cell or range. But I want to store the
> >> > web
> >> > content in variables first. Any hints?
> >> >
> >> > "Don Guillett" wrote:
> >> >
> >> >>
> >> >> Just send the email
> >> >> --
> >> >> Don Guillett
> >> >> Microsoft MVP Excel
> >> >> SalesAid Software
> >> >> dguillett1@austin.rr.com
> >> >> "Mak" <Mak@discussions.microsoft.com> wrote in message
> >> >> news:4C9F2F37-B153-4AF3-87F8-F2D7CE81636A@microsoft.com...
> >> >> > Could you pls guide me how to access
> >> >> > xltraders-subscribe@yahoogroups.com
> >> >> > step
> >> >> > by step? Thanks in advance.
> >> >> >
> >> >> > "Don Guillett" wrote:
> >> >> >
> >> >> >> goto
> >> >> >> xltraders-subscribe@yahoogroups.com
> >> >> >> and look in the files section. There are several free files.
> >> >> >> I have a couple of free files under author donalb36
> >> >> >>
> >> >> >>
> >> >> >> --
> >> >> >> Don Guillett
> >> >> >> Microsoft MVP Excel
> >> >> >> SalesAid Software
> >> >> >> dguillett1@austin.rr.com
> >> >> >> "Mak" <Mak@discussions.microsoft.com> wrote in message
> >> >> >> news:DC661F69-6B4C-4FA5-ABCF-5035BC861F75@microsoft.com...
> >> >> >> > Hi all, I want to get web content into Excel and store it to
> >> >> >> > variables
> >> >> >> > (not
> >> >> >> > in the Cells), how can I do it? I know WinHttp can help but I do
> >> >> >> > not
> >> >> >> > know
> >> >> >> > how
> >> >> >> > to 'include' WinHttp in Excel. Please help.
> >> >> >>
> >> >> >>
> >> >>
> >> >>
> >>
> >>
>
>