![]() |
communication
I believe there is a InternetSetStatusCallback function which will do what
your after. http://support.microsoft.com/default...b;EN-US;189850 -- Rob van Gelder - http://www.vangelder.co.nz/excel "Daniel" wrote in message ... Hi there, I would like to write an application in VBA which communicates with a servlet. That has been done with excel 2002 by "using" wininet.dll for this purpose but my problem is that when I send a request to the servlet, the excel stops working until it receives the requested data. How can I solve this problem? I've thought about using threads, but I don't know where to start. Is excel 2003 a better option in this case? Any ideas will be apperciated. Thanks Daniel |
communication
This site does not provide me enough info as a beginner in the VB world... Can you help me integrate it into a source code somehow
this is my routine for connecting and retrieving data as of now Public Function Connect(requestCommand As String) As Strin Const INTERNET_OPEN_TYPE_PRECONFIG = Const INTERNET_SERVICE_HTTP = Dim returnString As Strin Dim sBuffer As String * 204 Dim Result As Strin Dim lBufferLength As Lon Dim msg As Strin Dim INTERNET_DEFAULT_HTTP_POR Dim HTTP_QUERY_CONTENT_LENGT Const INTERNET_FLAG_RELOAD = &H8000000 Dim errorMsg As Strin Dim fullCommand As Strin Dim hSessio lBufferLength = Len(sBuffer hInternetOpen = hInternetConnect = hHttpOpenRequest = errorMsg = " fullCommand = ThisWorkbook.ServletName + requestComman INTERNET_DEFAULT_HTTP_PORT = ThisWorkbook.ServletPor hInternetOpen = InternetOpen("CD", INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0 If (hInternetOpen = 0) The returnString = "Error errorMsg = "Cannot initialize the internetconnection! GoTo endFunctio End I hInternetConnect = InternetConnect(hInternetOpen, ThisWorkbook.ServletUrl, INTERNET_DEFAULT_HTTP_PORT, vbNullString, vbNullString, INTERNET_SERVICE_HTTP, 0, 0 If (hInternetConnect = 0) The returnString = "Error errorMsg = "Cannot access the servlet GoTo endFunctio End I hHttpOpenRequest = HttpOpenRequest(hInternetConnect, "POST", fullCommand, vbNullString, vbNullString, 0, INTERNET_FLAG_RELOAD, 0 If (hHttpOpenRequest = 0) The returnString = "Error errorMsg = "Error in opening the requestchannel GoTo endFunctio End I bRet = HttpSendRequest(hHttpOpenRequest, vbNullString, 0, 0, 0 If (bRet = 0) The returnString = "Error errorMsg = "Error in sending request GoTo endFunctio End I HttpQueryInfo hHttpOpenRequest, HTTP_QUERY_CONTENT_LENGTH, ByVal sBuffer, lBufferLength, InternetReadFile hHttpOpenRequest, sBuffer, ByVal lBufferLength, lBufferLengt Result = " Result = Result + Left$(sBuffer, lBufferLength While lBufferLength < InternetReadFile hHttpOpenRequest, sBuffer, ByVal lBufferLength, lBufferLengt Result = Result + Left$(sBuffer, lBufferLength Wen bRet = InternetCloseHandle(hHttpOpenRequest bRet = InternetCloseHandle(hInternetConnect bRet = InternetCloseHandle(hInternetOpen returnString = Resul Connect = returnStrin Exit Functio endFunction msg = MsgBox(errorMsg, vbCritical, "Error" Connect = returnStrin End Functio |
All times are GMT +1. The time now is 12:15 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com