Solved

vba code works in ie10 but not ie11

Posted on 2013-12-13
18
3,338 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 83

Expert Comment

by:Dave Baldwin
ID: 39718156
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
ID: 39718865
Luckily, I am using vba, not vbscript.
0
 
LVL 83

Expert Comment

by:Dave Baldwin
ID: 39718991
I don't see any of your code in the file that you posted.  Where is it running?  What program is running it?
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 
LVL 5

Author Comment

by:rberke
ID: 39719278
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 83

Expert Comment

by:Dave Baldwin
ID: 39719319
"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
ID: 39719402
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 83

Expert Comment

by:Dave Baldwin
ID: 39719421
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
ID: 39723136
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
 
LVL 5

Author Comment

by:rberke
ID: 39723690
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
ID: 39723705
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 83

Expert Comment

by:Dave Baldwin
ID: 39724727
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
ID: 39725474
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 83

Expert Comment

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

Expert Comment

by:Rob Jurd, EE MVE
ID: 39725778
*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
ID: 39725780
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
ID: 39726695
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
This article descibes how to create a connection between Excel and SAP and how to move data from Excel to SAP or the other way around.
This Micro Tutorial demonstrates in Microsoft Excel how to consolidate your marketing data by creating an interactive charts using form controls. This creates cool drop-downs for viewers of your chart to choose from.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

776 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