Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
MAK MAK is offline
external usenet poster
 
Posts: 20
Default How do I use WinHttp within Excel 2003 Macro?

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.
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 122
Default How do I use WinHttp within Excel 2003 Macro?

Within the VBA project, you need to use menu option Tools
References, then add the XMLHTTP reference library (Microsoft XML, x.
0).

On Jun 17, 3:47 am, Mak wrote:
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.


  #5   Report Post  
Posted to microsoft.public.excel.programming
MAK MAK is offline
external usenet poster
 
Posts: 20
Default How do I use WinHttp within Excel 2003 Macro?

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

"Mak" wrote in message
...
Could you pls guide me how to access

step
by step? Thanks in advance.

"Don Guillett" wrote:

goto

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

"Mak" wrote in message
...
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.






  #7   Report Post  
Posted to microsoft.public.excel.programming
MAK MAK is offline
external usenet poster
 
Posts: 20
Default How do I use WinHttp within Excel 2003 Macro?

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

"Mak" wrote in message
...
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

"Mak" wrote in message
...
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

"Mak" wrote in message
...
Could you pls guide me how to access

step
by step? Thanks in advance.

"Don Guillett" wrote:

goto

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

"Mak" wrote in message
...
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.








  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 239
Default How do I use WinHttp within Excel 2003 Macro?

On Jul 19, 3:53*pm, Mak wrote:
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

"Mak" wrote in message
...
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

"Mak" wrote in message
...
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

"Mak" wrote in message
...
Could you pls guide me how to access

step
by step? *Thanks in advance.


"Don Guillett" wrote:


* * * goto
* * *
* * * 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

"Mak" wrote in message
...
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.- Hide quoted text -


- Show quoted text -


HI,
I have tried above code and function but it fatches nothing.
No errors but debug.pring is nothing.

Any idea?
It might be quite usefull to me.

Regards,
Madiya
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
excel 2003 + macro help Neil Holden Excel Discussion (Misc queries) 2 March 17th 10 05:56 PM
how to run acces 2003 macro in excell 2003 macro gonggo Excel Discussion (Misc queries) 0 October 6th 09 11:45 AM
Macro - Help Please Excel 2003 Paul Excel Discussion (Misc queries) 6 June 23rd 09 03:19 AM
excel 2003 macro help Martin Holzke Excel Programming 3 November 2nd 05 12:57 PM
macro in excel 2003 constance Excel Worksheet Functions 1 March 21st 05 09:50 AM


All times are GMT +1. The time now is 04:05 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"