[Last Call] Learn how to a build a cloud-first strategyRegister Now


Help Writing to an Input Field in IE from VBA

Posted on 2012-09-19
Medium Priority
Last Modified: 2012-09-25
Hello - I need to figure out how to write to a specific field and click on a button in Internet Explorer from my VBA project within an Access database.  I do this all the time with other sites, but can't figure out the proper "path" to these fields.

The url is http://www.swmc.com/swmc/wholesale_lender/broker/compensation_schedule.php

The page takes a while to load completely.

I need to fill the "Enter Company Code*" field and then click on the "Print Compensation Schedule" button.

Below is an example of the code I usually use for this type of thing, but I just can't figure out how to reference these fields.

       IE.Document.frames(1).Document.Forms(0).Document.all("USER_ID").Value = un
       IE.Document.frames(1).Document.Forms(0).Document.all("PASSWORD").Value = pw

Question by:rsburge
  • 5
  • 3
LVL 35

Expert Comment

ID: 38415687
One thing you could try is gettting rid of frames(1), as far as I can see the fields you are interested in aren't in a frame.

The problem with doing this sort of thing is that ever page/site is different, so you should look at the source code, and refer back to it, when writing your code.

Author Comment

ID: 38416037
The example above is just an example.  I have hundreds of these in my project and most all of them are unique.

I have been trying to work through the source code and have tried multiple variations for referencing the field based on what I am seeing in the source code, but I must be missing something because I can't get anything to work.

I'm hoping someone can look at the source code and figure out what the path is, because I am just not getting the right path.

Expert Comment

ID: 38416119
IE.Document.getElementByID("body:c:companyCode").Value = companyCode
Restore individual SQL databases with ease

Veeam Explorer for Microsoft SQL Server delivers an easy-to-use, wizard-driven interface for restoring your databases from a backup. No expert SQL background required. Web interface provides a complete view of all available SQL databases to simplify the recovery of lost database


Author Comment

ID: 38416151
Hi - These both return a run time error 91 - Object variable or With block variable not set.

Author Comment

ID: 38416158
I believe it needs to be something beyond IE.Document because when I run through the elements at ie.document, none of the elements in that compensation window are listed.

Expert Comment

ID: 38416269
Ok... my issue is with the fact that is in an iframe.  I will look at this tomorrow morning if I have time...

Author Comment

ID: 38416291
I saw that iframe but I haven't ever run across that before and didn't realize it could be an issue.

Thank you for your help, I really appreciate it.  I have been trying to figure this one out for going on 3 days now.  :)

Have a great night!

Accepted Solution

fhlio_admin earned 2000 total points
ID: 38424735
Sorry it has taken me a bit to respond.  We had some things going on at the home-front.

The best suggestion I can find about this particular website and how it is constructed, is to call the iframe separately, like the following:

Option Compare Database
Option Explicit

Function Q27871063_1()
Dim ieApp As InternetExplorer, ieTag As Object

Set ieApp = New InternetExplorer: ieApp.Visible = True
ieApp.Navigate "http://www.swmc.com/swmc/wholesale_lender/broker/compensation_schedule.php"

Do While ieApp.Busy Or ieApp.ReadyState <> READYSTATE_COMPLETE
Set ieTag = ieApp.Document.getElementByID("compensation")

ieApp.Navigate ieTag.src

Do While ieApp.Busy Or ieApp.ReadyState <> READYSTATE_COMPLETE

Set ieTag = ieApp.Document.getElementByID("body:c:companyCode")
ieTag.Value = "XYZ"
Set ieTag = ieApp.Document.getElementByID("body:c:_idJsp14")

End Function

Open in new window


Author Closing Comment

ID: 38433617
This works perfectly!!  Thank you so much!!!

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

Question has a verified solution.

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

Microsoft Access has a limit of 255 columns in a single table; SQL Server allows tables with over 255 columns, but reading that data is not necessarily simple.  The final solution for this task involved creating a custom text parser and then reading…
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

834 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