We help IT Professionals succeed at work.

IE 7 problems with MS Excel Macros, Javascript form

mattieflo used Ask the Experts™

Our department uses Excel Macros in IE 6 to take information off a spreadsheet and enter it on a Javascript form. It works fine, but however when some of our computers got upgraded to IE 7, the macro's timing somehow was throw off. I've tried to insert pause breaks in between commands in VBA, but that doesn't seem to help. Adding RAM to those computers also did not help any. Would any of you folks have any idea on how to start with this?

Many thanks!
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Can you please provide few more details about the code and the data in question?

It would be easier to help with some additional details like which website, size of data, macro code etc.
NorieAnalyst Assistant

It really would help to see some more information, perhaps even the code.

I don't see how the form being 'javascript' affecting things.

What mmethods are you currently using to wait?

When you say you are using 'Excel Macros in IE6' do you mean you have code in Excel that is automating IE, taking data from a spreadsheet, entering that in the form etc


Ok guys here's sample code. Also I realize I maybe using incorrect terminology just like 'javascript forms' so just bear with me and i'll do my best to describe it.

So the user has an Excel spreadsheet, highlights some information on the spreadsheet and then hits a button to run a macro. The following code is one of those macros.

Sub tag_order()
    Dim OriginalRow As Integer
    Dim OriginalCol As Integer
    Dim NumAreas As Integer
    Dim NumRowsInSelection As Integer
    Dim i As Integer
    Dim j As Integer
    Dim k
    Dim single_row As Range
    Dim single_column As Range

    OriginalRow = ActiveCell.row
    OriginalCol = ActiveCell.Column
    NumAreas = Selection.Areas.Count
    AppActivate "Retek - prd"
    Send_Keys_Then_Wait "{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}"
    Send_Keys_Then_Wait "553213261" & "{tab}{tab}"
    Send_Keys_Then_Wait "CO" & "{tab}"
    Send_Keys_Then_Wait "78" & "{tab}{tab}{tab}{tab}{tab}{tab}"
    Send_Keys_Then_Wait Selection.Rows(1).EntireRow.Cells(19).Text, 0, 1
    Send_Keys_Then_Wait "{tab}"
    Send_Keys_Then_Wait Selection.Rows(1).EntireRow.Cells(20).Text, 0, 1
    Send_Keys_Then_Wait "%{t}", 0, 1
    Send_Keys_Then_Wait "{down}{down}", 0, 1
    Send_Keys_Then_Wait "{enter}", 0, 1
    Send_Keys_Then_Wait "16", 0, 1
    Send_Keys_Then_Wait "%{o}", 0, 1
    Send_Keys_Then_Wait "{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}"
    Send_Keys_Then_Wait "MN" & "{tab}"
    Send_Keys_Then_Wait "%{i}", 0, 1
    Send_Keys_Then_Wait "%{b}", 0, 1
    Send_Keys_Then_Wait "{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}{tab}"
    Send_Keys_Then_Wait " ", 0, 1
    Send_Keys_Then_Wait "%{f}" & "%{p}", 0, 1
End Sub

Public Sub Send_Keys_Then_Wait( _
    str, Optional seconds_before = 0, Optional seconds_after = 0)

    If seconds_before >= 0 Then WaitTime seconds_before
    SendKeys str, True
    If seconds_after >= 0 Then WaitTime seconds_after
End Sub
Retek - PRD is a Oracle form that opens up in a web browser. When we ran this macro in IE6, it ran perfectly. As soon as we upgraded to IE7, it threw the timing off these macros off where they break down and send key strokes in the wrong boxes. Do you guys know what things to look for that could have caused that timing issue?
NorieAnalyst Assistant

I think if you search here, and probably anywhere else, you'll find that using SendKeys is not the best way of doing this sort of thing.

I would almost go as far as to say it's the worst but I do know that that method is needed sometimes.

Can you open this form/webpage/whatever in IE7/8 using a hyperlink or some other method?

Or are you working with an existing instance of it?


Correct, the form in IE 7 is already open when this macro button is pressed.

Let me ask, what other alternative exists other than SendKeys?
You can use this sample VBA code to input values on a webpage:

I had tested it on the attached html page. You may need to explore the source code of the webpage you are filling informtion.

Save this file to C:\Temp folder and try this code from Excel VBA.

Sub test()
Set IE = CreateObject("InternetExplorer.Application")

IE.Navigate "C:\temp\testing.html"
IE.Visible = True

Do While IE.ReadyState <> 4

IE.Document.Forms("testForm1").Item("FN").Value = "Test First Name"
IE.Document.Forms("testForm1").Item("LN").Value = "Test Last Name"

End Sub

Open in new window



Thanks I think that's what im looking for, i'll give it a shot.
Hello mattieflo:

Did above code help you?