feeding url from activeCell doesn't work

avathar

New Member
Joined
Apr 8, 2019
Messages
2
Hi,
i'm trying to write simple script to check webpage status. And i have a problem with feeding url address from active cell.

Code:
Public Function GetServerResponse(url As String) As Integer

    On Error Resume Next


    With CreateObject("WinHttp.WinHttpRequest.5.1")
        .Open "GET", url
        .send
        GetServerResponse = .Status
    End With
Debug.Print GetServerResponse


ActiveCell.Offset(0, 1).Value = GetServerResponse
ActiveCell.Offset(1, 0).Select


End Function


Sub checkURLstatus()


'GetServerResponse "http://google.com/"
GetServerResponse ActiveCell.Value




End Sub

So if i put "http://google.com/" to active cell, script won't work.
if i use GetServerResponse "http://google.com/" instead, script will work.

Can some one please tell me, why url address in active cell isn't recognized properly ?
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I don't know for sure (because I do not do code that interacts with the web), but I think this is a limitation of formulas in Excel... they cannot take any action, only return a value to the cell they are in. I believe opening a web page would be considered an action. I think you will have to use a macro and call it when you need to do what you want.
 
Upvote 0

Forum statistics

Threads
1,214,979
Messages
6,122,561
Members
449,089
Latest member
Motoracer88

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top