473,608 Members | 2,425 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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="rethi nkChargeCurrenc y(1)". This
suggests a variable, rethinkChargeCu rrency(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 InternetExplore r
Dim i As Integer
Dim nm as String

'Open Web
Set IeApp = New InternetExplore r
IeApp.Visible = True
IeApp.Navigate "http:\\WebAddr essGoesHere.com "
Do: Loop Until IeApp.ReadyStat e = READYSTATE_COMP LETE

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).V alue = "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).s electedIndex = 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 17942
The following solution was posted in the
microsoft.publi c.excel.program ming 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...@h otmail.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).V alue = "S" & i

Try whether doing
.elements(nm).o nchange
here helps.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
ch***********@h otmail.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="rethi nkChargeCurrenc y(1)". This
suggests a variable, rethinkChargeCu rrency(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 InternetExplore r
Dim i As Integer
Dim nm as String

'Open Web
Set IeApp = New InternetExplore r
IeApp.Visible = True
IeApp.Navigate "http:\\WebAddr essGoesHere.com "
Do: Loop Until IeApp.ReadyStat e = READYSTATE_COMP LETE

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).V alue = "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).s electedIndex = 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
5619
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 = Dispatch("InternetExplorer.Application") ie.Visible = 1 ie.Navigate("http://www.cnn.com") if ie.Busy:
6
4336
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 developers, but is relevant discussion. i'm not OT here unless someone thinks i'm trolling (which i'm not, obviously). then i'll disappear and never show my face again. :P
12
19576
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 running instances of Internet Explorer (I mean those that the user launches himself). I know this is possible because I did it three months ago. Unfortunately, I can't find the code. I've already looked at all the Microsoft articles on automating...
6
4582
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 somewhere on the screen with the mouse left button (I'm not sure this button can be pressed directly via keysequence, not via mouse, but it does have a name).
4
3191
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 Access database form: 1. Navigate to URL and click button 2. Enter user name and password 3. Apply filters (enter criteria in text boxes) 4. Execute query (another button click) 5. Export results to network server 6. Data mining using Monarch...
0
2899
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"); Response.ContentType = "application/vnd.ms-excel";
1
3095
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
3227
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
1282
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 series of options depending on the option selected in drropdown A. While I can select from dropdown A in VBA, dropdown B never gets updated. Prsumably I need to trigger some event on the page, but how do I accomplish this in VBA? 2) clicking a...
0
8010
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8157
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8349
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6820
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6015
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3967
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4030
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2477
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1607
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.