Wednesday, July 19, 2017

VBA: Runtime Error '70' when accessing a database

Leave a Comment

I have an .xlsm-file. It contains a list of movies, and is supposed to search the online database omdbapi.com for information on each movie, and insert this information, starting in column F.

A MWE looks as follows.

In the first sheet, it says just Lawless (2012) in cell A1, the name of the first movie. Columns 4 and 5 contain the name with spaces turned to + and the year extracted from the first cell, respectively, but I skip that code here. In the example, it looks like this:

enter image description here

The VBA macro is as follows:

Sub test()  mystr = "http://www.omdbapi.com/?t=" & Cells(1, 4).Value & "&y=" & Cells(1, 5).Value & "&r=xml"         ActiveWorkbook.XmlImport URL:=mystr, ImportMap:=Nothing, Overwrite:=True, Destination:=Cells(1, 6)             ActiveWorkbook.Connections.Item(1).Delete  End Sub 

This has code has worked for the longest time. Now, I encounter the error:

Run-time error '70':

Permission denied.

I searched what that means, but did not find anything that seemed applicable. Furthermore, the internet connection is working and not clogged up by other connections, and excel has all rights to access the web.

1 Answers

Answers 1

please try this ... the result may answer your question about the code 70

Sub test()      mystr = "http://www.omdbapi.com/?t=" & Cells(1, 4).Value & "&y=" & Cells(1, 5).Value & "&r=xml"      Debug.Print mystr       ' copy the url from the "Immediate window"                             ' and paste into a web browser address bar,                             ' then navigate to that webpage                             ' (view immediate window by pressing ctrl-G)  End Sub 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment