Solved

vba code works in ie10 but not ie11

Posted on 2013-12-13
18
3,195 Views
Last Modified: 2013-12-18
the following code snippet works in ie10, but not with ie11.


    Do: Sleep 100: Loop While .Busy
    .Document.getElementById("ctl00_ContentPlaceHolder_cbSelectDatapoints").Click
    Do: Sleep 100: Loop While .Busy
    .Document.getElementById("ctl00_ContentPlaceHolder_cbSelectDatapoints").Checked = True
    Do: Sleep 100: Loop While .Busy
    
    .Document.getElementById("ctl00_ContentPlaceHolder_cbAll").Click
    Do: Sleep 100: Loop While .Busy
    .Document.getElementById("ctl00_ContentPlaceHolder_cbAll").Checked = True
    Do: Sleep 100: Loop While .Busy

Open in new window


Line 7 gets and error 424 object required.

 
It is acting as if I had misspelled ctl00_ContentPlaceHolder_cbAll

I can't figure it out.

rberke

P.S. I had the identical error message elsewhere, but I solved it by changing "Tagname" instead of "TagName".  Ie10 did not care as much about lowercase and upper case.
Clearly, that is not what is causing today's problem.


I have attached a file with the snipped HTML code.
html-in-text-file.txt
0
Comment
Question by:rberke
  • 6
  • 6
  • 4
18 Comments
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
VBscript has been deprecated in IE11 and in some cases, does not work at all.
http://msdn.microsoft.com/en-us/library/ie/dn384057%28v=vs.85%29.aspx
0
 
LVL 5

Author Comment

by:rberke
Comment Utility
Luckily, I am using vba, not vbscript.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
I don't see any of your code in the file that you posted.  Where is it running?  What program is running it?
0
 
LVL 5

Author Comment

by:rberke
Comment Utility
It is running under excel 2010 in an offce 2010 pro/ windows 7 pro environment.  

Paste the following into a vba module and run it
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Sub test()
Dim ieobj As Object
Set ieobj = CreateObject("InternetExplorer.Application")
With ieobj
    .Visible = True
    .navigate "http://www.slforms.universalservice.org/DRT/Default.aspx"
    Do: Sleep 100: Loop While .Busy
    .Document.getElementById("ctl00_ContentPlaceHolder_ddlFundingYear").Value = 2013
    Do: Sleep 100: Loop While .Busy
    .Document.getElementById("ctl00_ContentPlaceHolder_BEN").Value = 12345
    Do: Sleep 100: Loop While .Busy
    .Document.getElementById("ctl00_ContentPlaceHolder_cbSelectDatapoints").Click
    Do: Sleep 100: Loop While .Busy
    .Document.getElementById("ctl00_ContentPlaceHolder_cbSelectDatapoints").Checked = True
    Do: Sleep 100: Loop While .Busy
    .Document.getElementById("ctl00_ContentPlaceHolder_cbAll").Click  ' <===== here is the problem
    Do: Sleep 100: Loop While .Busy
    .Document.getElementById("ctl00_ContentPlaceHolder_cbAll").Checked = True
    Do: Sleep 100: Loop While .Busy
End With


End Sub

Open in new window

0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
"ctl00_ContentPlaceHolder_cbAll" doesn't exist in the page until after you check the box for "ctl00_ContentPlaceHolder_cbSelectDatapoints".  Does the page work in IE11 directly?  I don't have it so I can't check.

I suggest you click on "Request Attention" above and get the Excel and VBA Topic Areas added to your question.  The Web Development Software Topic Area is more about writing server side code and HTML to generate web pages.
0
 
LVL 5

Author Comment

by:rberke
Comment Utility
Yes, the page works when manipulated manually.  By the way, you can run the code from any of the major vba apps. Excel or Word or Outlook.  I will request attention but, i have a strong feeling the problem is not with vba
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
The problem may not be with your VBA since it worked before.  But this Topic Area won't normally get attention from anyone who really knows.  I just happen to check all the zones out of curiosity to see what people are asking about.
0
 
LVL 42

Accepted Solution

by:
Rob Jurd, EE MVE earned 500 total points
Comment Utility
it's likely to do with the markup as there's errors in it and IE11 is much less forgiving

http://validator.w3.org/check?uri=http%3A%2F%2Fwww.slforms.universalservice.org%2FDRT%2FDefault.aspx&charset=%28detect+automatically%29&doctype=Inline&group=0

I'm trying to track it down for you but it's going to be a badly closed tag etc
0
How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

 
LVL 5

Author Comment

by:rberke
Comment Utility
Ugh, it comes from a government website, so it will not be fixed for a very long time.

I guess I'll have to revert to IE10.  

What do you mean when you say you'll try "to track it down" ?  Doesn't the validation output option already do that?  Of course, lots of that output appears to be overly picky, so perhaps the website is perfect, but the validator is wrong?

In either case, I do not intend to forward the problem to the government agency. They have much bigger problems to worry about than my silly little vba program.
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
Comment Utility
Doesn't matter as it's not your website.... so its not possible at this stage. Since my laSt post I was able to get it working with a copy of the site on my own domain with the offending elements removed. ... Can't get that time back can I!? :)
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
I don't see it as being overly picky.  We see a lot of invalid HTML code here.  Sometimes all it takes to break a page is to leave off a closing tag, especially on a comment.  Doing that make the rest of the page part of that comment.

And "overly picky" is a human viewpoint.  When rendering web pages, computers go by the rules and have no sense of being picky though browsers are written to try to show a page as best they can.  They still don't "know what you meant".

The rules that the browser is supposed to use are defined by the DOCTYPE at the top of the page.  And one of the things that happens fairly often is people think they are 'upgrading' their page by putting a newer DOCTYPE at the top of the page and never checking to see if their page is using the rules for that DOCTYPE.  Running your page thru the Validator is the easiest and quickest way to do that.
0
 
LVL 5

Author Comment

by:rberke
Comment Utility
Murphy's law strikes again.  I reverted to IE10.  The error message goes away, but the program still doesn't work  !!!!

I'll bet 10 to 1 that the SLD (the government sponsored company) has broken the web site recently.  This is a fairly big problem for me, but I will survive.

Since you have done the work to fix it, please attach  your revised version and  I will forward it to  them. They may actually fix it.  

If you have already deleted it, don't worry about it.
0
 
LVL 82

Expert Comment

by:Dave Baldwin
Comment Utility
I'll bet they say they "fixed" it...
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
Comment Utility
*laughs* , exactly Dave!

As for the validated html - I fixed the errors that were in the validator as well as tried opening it in xmlnotepad and fixed the errors it gave me.  Nothing special but it did the job.
0
 
LVL 42

Expert Comment

by:Rob Jurd, EE MVE
Comment Utility
This is the html file that worked for me.  also attached the xlsm for you to view.  I was using my own site as you'll see in the link.
index.html
Book1.xlsm
0
 
LVL 5

Author Closing Comment

by:rberke
Comment Utility
Great work and MUCH appreciated.

I'll send it to the government agency. They give every request a tracking number, so it won't get "lost". It may even get fixed as this particular web page is very heavily used by thousands of users.

Thanks again
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article will show you how to use shortcut menus in the Access run-time environment.
No matter the version of Windows you are using, you may have some problems with Windows Search running too slow or possibly not running at all. Before jumping into how you can solve this issue, just know there are many other viable alternative deskt…
This Micro Tutorial will demonstrate how to create pivot charts out of a data set. I also added a drop-down menu which allows to choose from different categories in the data set and the chart will automatically update.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now