View Full Version : MSXML2.XMLHTTP
smallzoo
09-01-2011, 11:41 AM
Not sure where to put this..
I have successfully run the following code from access 2007 vba where xxxxxxxxx is the url I am calling
Dim strResponse As String
Dim objHttp As Object
Set objHttp = CreateObject("MSXML2.XMLHTTP")
objHttp.Open "Get", "xxxxxxxxxxxx", False
objHttp.send
strResponse = objHttp.responseText
Set objHttp = Nothing
But I dont want the returned html code I just want the actual URL string returned
Can anyone help ?
thanks
orange
09-01-2011, 04:53 PM
Please tell us exactly what you are trying to do. There may be options.
Aren't you supplying the url when you create the Get ......
smallzoo
09-02-2011, 01:49 AM
the "xxxxxxxxxxxx" url is a web service which is a url address with parameters. The webservice return a URL address which I would then like to load.
I have done this job successfuly using a little c# application but due to security on the client's PC it would be safer to run the function within a VBA module in access hence what I am trying to do.
In c# there is would have been an attribute objHttp.responseUri which return the URL but I dont seem to have that
Thanks
JP2112
09-02-2011, 05:49 AM
I'm confused as well. You want the URL that is at the end of your query. But isn't that the same as the URL you supplied?
For example if I call the bit.ly API with this URL:
http://api.bitly.com/v3/shorten?login=myLogin&apiKey=myKey&longUrl=http://www.vbaexpress.com/
Then that is the URL returned by the API.
orange
09-06-2011, 07:05 AM
Not sure where to put this..
I have successfully run the following code from access 2007 vba where xxxxxxxxx is the url I am calling
Dim strResponse As String
Dim objHttp As Object
Set objHttp = CreateObject("MSXML2.XMLHTTP")
objHttp.Open "Get", "xxxxxxxxxxxx", False
objHttp.send
strResponse = objHttp.responseText
Set objHttp = Nothing
But I dont want the returned html code I just want the actual URL string returned
Can anyone help ?
thanks
Can you parse your strResponse once it is received?
Shred Dude
09-18-2011, 04:10 PM
Instead of using the xmlhttp approach, you might try doing the original URL in an Internet Explorer object. After the document loads, you can then return the IE object's .locationurl property to get the URL that was returned.
Very rough example...
Public Function returnURL(sURL As String) As String
'---------------------------------------------------------------------------------------
' Procedure : returnURL
' Author : Shred Dude
' Date : September 18, 2011 - 16:06
' Purpose : return the URL from a given URL's response
'---------------------------------------------------------------------------------------
'
Const sPROCEDURE As String = "returnURL"
Dim IE As Object
Set IE = CreateObject("internetexplorer.application")
With IE
.navigate sURL
While .readystate <> 4
DoEvents
Wend
returnURL = .locationurl
End With
Set IE = Nothing
End Function
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.