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 ?
 

Some videos you may like

Excel Facts

Fastest way to copy a worksheet?
Hold down the Ctrl key while dragging tab for Sheet1 to the right. Excel will make a copy of the worksheet.

Rick Rothstein

MrExcel MVP
Joined
Apr 18, 2011
Messages
36,722
Office Version
  1. 2010
Platform
  1. Windows
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.
 

avathar

New Member
Joined
Apr 8, 2019
Messages
2
hmm it looks like i made mistake in a url format in cell. It is working now...
 

Watch MrExcel Video

Forum statistics

Threads
1,123,514
Messages
5,602,093
Members
414,501
Latest member
mdhaumyu

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
Top