473,407 Members | 2,546 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,407 software developers and data experts.

Automating Internet Explorer with Excel VBA and JavaScript

Hi,

I'm trying to use Excel VBA ('97) to send details from an Excel sheet
to a web page. I'm having some success but I've one issue that's
proved difficult to find in the archives.

There are a number of elements (ie. text boxes) on this web page that
are conditionally "greyed out". They should become visible (ie. not
greyed) when a prior element is entered with data. However, this is
not happening. The elements are being filled, but they are not
becoming visible.

As a result, when I click the "Submit" button at the bottom of the
page, I get error messages saying these elements are required. Data
has definitely been entered into these elements, but because the
elements do not become un-greyed, I suspect the data is not being
captured.

I viewed the source code and found what looks like a command associated
with these elements: onchange="rethinkChargeCurrency(1)". This
suggests a variable, rethinkChargeCurrency(1) is being changed upon a
change in the element. However, I could not find any further reference
to this variable.

I've not much knowledge of JavaScript and I wonder if I need to put a
check in my code to "enable" these fields? Or do I need to change this
variable?

I've put an example skeleton of my code below. Hope it is sufficiently
illustrative.

Many thanks in advance for any help provided.

Regards,
Chris Adams

Sub startIexplore()

Dim IeApp As InternetExplorer
Dim i As Integer
Dim nm as String

'Open Web
Set IeApp = New InternetExplorer
IeApp.Visible = True
IeApp.Navigate "http:\\WebAddressGoesHere.com"
Do: Loop Until IeApp.ReadyState = READYSTATE_COMPLETE

With IeApp.Document.forms("form")
' Fill in names - these are the elements that need to be filled
in to un-grey the others
For i = 0 To 4
nm = "sources[" & i & "].name"
.elements(nm).Value = "S" & i
Next i

' Type - these are the elements that will be un-greyed, upon
completion of "names"
For i = 0 To 4
nm = "sources[" & i & "].type"
.elements(nm).selectedIndex = 2
Next i

.submit ' I get error messages on the following pages,
saying the "types are required"

End With

IeApp.Quit

End Sub

(I've made an assumption that cross-posting is acceptable in this case,
sorry if not).

Aug 30 '06 #1
1 17925
The following solution was posted in the
microsoft.public.excel.programming newsgroup.
It worked, although I had to be selective with which elements I
included the statement (not sure why, I'll try to work the reason out
for this later).

Regards,
Chris Adams
chris_j_ad...@hotmail.com wrote:
With IeApp.Document.forms("form")
' Fill in names - these are the elements that need to be filled in to un-grey the others
For i = 0 To 4
nm = "sources[" & i & "].name"
.elements(nm).Value = "S" & i

Try whether doing
.elements(nm).onchange
here helps.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
ch***********@hotmail.com wrote:
Hi,

I'm trying to use Excel VBA ('97) to send details from an Excel sheet
to a web page. I'm having some success but I've one issue that's
proved difficult to find in the archives.

There are a number of elements (ie. text boxes) on this web page that
are conditionally "greyed out". They should become visible (ie. not
greyed) when a prior element is entered with data. However, this is
not happening. The elements are being filled, but they are not
becoming visible.

As a result, when I click the "Submit" button at the bottom of the
page, I get error messages saying these elements are required. Data
has definitely been entered into these elements, but because the
elements do not become un-greyed, I suspect the data is not being
captured.

I viewed the source code and found what looks like a command associated
with these elements: onchange="rethinkChargeCurrency(1)". This
suggests a variable, rethinkChargeCurrency(1) is being changed upon a
change in the element. However, I could not find any further reference
to this variable.

I've not much knowledge of JavaScript and I wonder if I need to put a
check in my code to "enable" these fields? Or do I need to change this
variable?

I've put an example skeleton of my code below. Hope it is sufficiently
illustrative.

Many thanks in advance for any help provided.

Regards,
Chris Adams

Sub startIexplore()

Dim IeApp As InternetExplorer
Dim i As Integer
Dim nm as String

'Open Web
Set IeApp = New InternetExplorer
IeApp.Visible = True
IeApp.Navigate "http:\\WebAddressGoesHere.com"
Do: Loop Until IeApp.ReadyState = READYSTATE_COMPLETE

With IeApp.Document.forms("form")
' Fill in names - these are the elements that need to be filled
in to un-grey the others
For i = 0 To 4
nm = "sources[" & i & "].name"
.elements(nm).Value = "S" & i
Next i

' Type - these are the elements that will be un-greyed, upon
completion of "names"
For i = 0 To 4
nm = "sources[" & i & "].type"
.elements(nm).selectedIndex = 2
Next i

.submit ' I get error messages on the following pages,
saying the "types are required"

End With

IeApp.Quit

End Sub

(I've made an assumption that cross-posting is acceptable in this case,
sorry if not).
Aug 31 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: EricP | last post by:
I'm trying to figure out how to print from IE 6.0 using Python's Win32all com library. When I do from win32com.client import Dispatch from time import sleep ie =...
6
by: Charles Banas | last post by:
weird subject - i hope more than just one curious regular will hear me out. :) ok, i've got a bit of a big problem, and i need answers as soon as possible. i know this forum is meant for web...
12
by: SunshineGirl | last post by:
I'm trying to receive events from a running instance of Internet Explorer. So far I've only been able to receive events from an instance I launch from code, but I need to receive events from all...
6
by: tinkerman | last post by:
Hello net friends, I need to automate Internet Explorer in a very simple way. I need to: 1. press refresh (F5) on the currently loaded website. 2. press END button. 3. Click a button...
4
by: attachmatey | last post by:
Greetings: I'm looking for some help in automating (what I thought would be) a simple procedure in Internet Explorer. I'm trying to put the following operation under a button click in an MS...
0
by: Christian W Larsen | last post by:
I want to export a datagrid to Excel. Here is the code: Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition", "attachment;filename=FileName.xls");...
1
by: Christian W Larsen | last post by:
I want to export a datagrid to Excel. Here is the code: Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition",
2
by: cwlarsen | last post by:
I want to export a datagrid to Excel. Here is the code: Response.Clear(); Response.Buffer = true; Response.AddHeader("content-disposition",
3
by: Cliff | last post by:
I'm attempting to automate input to an ASP/AJAX web-page using VBA, however, I've encountered a couple of problems: 1) when selecting from dropdown A manuallly, dropdown B is populated with a...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.