VBA Runtime Error (Access is Denied) When Accessing HTML Page

FatLane

New Member
Joined
May 17, 2009
Messages
32
My application has been working fine for the last two and a half years. But today, all of the sudden I am getting the error:
Run-time error '-2147024891 (80070005)':
Access is denied.

Doing a little research this can be caused by a slew of possible reasons. I suspect it has something to do with a corrupted or altered system file or registry entry. I have not installed any new programs recently.

The error occurs when trying to access an HTML page. Here is the snippet of code where the error occurs.

Code:
  With CreateObject("MSXML2.XMLHTTP")
    .Open "GET", URL, False
    .setRequestHeader "User-Agent", UAgent
    .send
    TXT = .responseText
  End With

The error occurs at the .send line

I am running:
Windows 7
Excel 2013
VBA 7.1

If anyone has any ideas or experience with similar issues I would be greatly grateful.

-Brian
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
I tried one of my other applications that uses the same snippet but accesses a different URL. That application works just fine.

I then retrieved a backup copy of the file from a few days ago, when it was working fine. I am getting the same error.

I know my IP is not blocked, as I can still access the page directly from the browser.

I have changed user agent settings and that also had no effect.
 
Last edited:
Upvote 0
I have checked rights and permissions for the file and there isn't a problem there. All of my appropriate references are checked.

All of the other applications that run this code are working fine, this is the only file experiencing the problem.
 
Upvote 0
I am having the same trouble and it started yesterday, working perfectly up until then. Did you ever get it resolved?
In my case the code (very similar to yours and fails on the send) is in a loop and is executed multiple times to retrieve data from a web site with multiple pages. It processes correctly and receives all of the pages for one product but then on a change of product it fails.
I have a second PC with the same level Windows 10 and the same level Office 365 Business and it works perfectly.
Two other people who use my program also report it failing at the same point in the process.
Any advice or help greatly appreciated. I have tried every suggestion I could find on the internet without success.
 
Upvote 0
Could it be that the page/site you are trying to access has changed?
 
Last edited:
Upvote 0
Did you ever get it resolved?

The problem I had turned out to be that the URL I was using had changed. They switched to a secure server. Once I changed
Code:
http://
to
Code:
https://
it worked perfectly again.

I would double check your URLs and make sure the real life addresses match the ones your program is using.
 
Upvote 0
I doubt that it is a change to the website because the same code works perfectly on another PC. In fact I have tried it on 3 PC's and only 1 fails. Two PC's have the same configuration and one is Windows 7 which works. Only one of the Windows 10 PC's fail.
I also tried HTTPS which appears to work but on the second pass when it would normally fail because of the Access Denied error, it does not return any data.
 
Upvote 0
The problem I had turned out to be that the URL I was using had changed. They switched to a secure server. Once I changed
Code:
http://
to
Code:
https://
it worked perfectly again.

I would double check your URLs and make sure the real life addresses match the ones your program is using.

I just now ran in to this problem and your fix worked immediately. Thanks for the info.
 
Upvote 0

Forum statistics

Threads
1,215,561
Messages
6,125,533
Members
449,236
Latest member
Afua

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