Excel refresh returns "Please enable JavaScript to view the page content."

Adison

New Member
Joined
Jan 7, 2014
Messages
4
Long time Mr. Excel viewer. First time poster. Thanks beforehand.

Here's the problem - Excel refresh returns "Please enable JavaScript to view the page content."

Understand a work around to this is to right click, edit query, click on import. This works 75% of the time. Not all the time - with 25% of the time returning the JavaS error.

However, when attempting to macro around this problem, the resulting macro fails.

With Selection.QueryTable
.Connection = _
"URL;http://[surpressed www.]"
.CommandType = 0
.WebSelectionType = xlEntirePage
.WebFormatting = xlWebFormattingAll
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub

Here, ".CommandType = 0" returns a Run-time error '5'. There are some posts on this, but no solution.

When I rem out the ".CommandType..", you guessed it, the Java error returns.

I wrapped a loop around it to run until the error is gone. This loop runs in-definitely.

I've spent about three hours trying to fix this. Again, many thanks for your help.

HELP :)
 
Last edited:

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
Greetings Adison


Welcome to the forum.
Please See: Help Us Help You

In your OP, the url is suppressed, so we can't see what the page you are querying is publishing.

I can only say the CommandType = 0 is not valid; it must be one the the values specified below for XlCmdType.

Code:
Enum XlCmdType
    Const xlCmdCube = 1
    Const xlCmdSql = 2
    Const xlCmdTable = 3
    Const xlCmdDefault = 4
    Const xlCmdList = 5
End Enum


Enum XlWebSelectionType
    Const xlEntirePage = 1
    Const xlAllTables = 2
    Const xlSpecifiedTables = 3
End Enum
On that, assuming there are HTML Tables, instead of collecting the entire page, which would include the JavaScript, could try:

.CmdType = xlCmdTable '3
.WebSelectionType = xlSpecifiedTables '3
.WebTable = """tablename""" '

Note: the HTML will identify the table like:
HTML:
< table id="table3" class="graybox" >
 
Upvote 0
I've started experiencing the same problem with a website for which I previously had no issues (see code below).

Set ws = ActiveSheet
prefix = "http://www.asx.com.au/asx/statistics/todayAnns.do"
Set qt = ws.QueryTables.Add(Connection:="URL;" & prefix, Destination:=Range("A1"))
Cells.Select
Selection.Delete Shift:=xlUp
With Selection.Interior
.Pattern = xlNone
.TintAndShade = 0
.PatternTintAndShade = 0
End With
Range("A1").Select
qt.WebSelectionType = xlEntirePage
qt.Refresh BackgroundQuery:=False

Messaged received: Please enable JavaScript to view the page content.

When I go into edit the query, I get a message about a script error.

Any advice/assistance would be greatly appreciated.
 
Upvote 0
I am having same problem on same website. Neither querytable, nor a get using CreateObject("MSXML2.XMLHTTP.6.0") works.

Both return that gobbledegook with the "Please enable JavaScript to view the page content" heading despite javascript being turned on in IE.

Yet you can view the page no issue using 'view source' in the browser. very odd.

I was thinking it was a MS java security change, but maybe a change at ASX as we are both having it on the same day?
 
Upvote 0
Hi paulnb.

So it's not just me, and yes I'm thinking the ASX maybe have undertaken some changes over the weekend. I may have even read something in this regard last week but I'm not 100 per cent certain.

Hopefully, we can get a solution to this issue.

Cheers
 
Upvote 0
You can see the source code changes made on the internet archive. snapshot from 17th...

view-source:Previous trading day announcements - ASX

versus today:

view-source:Previous trading day announcements - ASX

I suspect related to that APM_DO_NOT_TOUCH section. I doubt there will be a solution to this for querytables. I am finding these harder and harder to use as the old school internet id progrssively broken. But to not even be able to retrieve the content via a vbscript get of the complete html in order to grep it is astonishing.
 
Upvote 0
Yes, I agree. My knowledge is very limited. Will wait and see if someone can provide a solution. If a solution arises somewhere else, I will post here.
 
Upvote 0
I have wasted a number of hours trying to do this with windows 10 powershell as that is apparently the path to the future. No luck.

Pretty easy to get a viable html file using a powershell script on the command line as such:

Invoke-WebRequest Previous trading day announcements - ASX -OutFile D:\Temp\getweb_tempout.txt

and I figured I could just loop through it and grep it after that and move away from these dying querytables but OMG. Powershell integration into VBA appears to be impossible. Something to do with it running as a separate user/session and I just get permissions errors and url unreachable errors, and Norton blocking all scripts due to trojan activity. The only way to resolve the last it to tell it to stop scanning ALL powershell activity and I certainly don't want to do that.

I still cannot think of a viable way forward now querytables are dead. If not powershell, then what?
 
Upvote 0

Forum statistics

Threads
1,213,558
Messages
6,114,296
Members
448,564
Latest member
ED38

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