473,473 Members | 4,185 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

VBA: Auto fill in form of open website

3 New Member
Dear all,

I already searched and found a lot solutions to navigate to a page by vba and fill in form controls.
However, I want to fill in form controls of an open window in IE, but I have no idea how to appoint the open IE window to use in VBA code.

Does anyone has an idea how to solve this issue?

Thanks in advance
Jun 15 '11 #1
1 8451
pod
298 Contributor
hope this helps a bit. Here is some code I use to get to a web page c/w frames and set a value to a field and submit the form to get the results...

Expand|Select|Wrap|Line Numbers
  1.  
  2. 'finds an open IE site by checking the URL
  3. Function GetOpenIEByURL(hvid As Long) As SHDocVw.WebBrowser
  4.     'hvid is the value I want to send in the form
  5.     Dim flag As Boolean
  6.     flag = False
  7.     Dim i_URL As String
  8.     Dim objIE As Object
  9.     i_URL = "http://some.website.com/frames.asp"
  10.     Dim objShellWindows As New SHDocVw.ShellWindows
  11.     'some error handling
  12.     On Error GoTo catchError
  13.     'loop over all Shell-Windows
  14.     Dim IEframes As FramesCollection
  15.     For Each GetOpenIEByURL In objShellWindows
  16.         'if the document is of type HTMLDocument, it is an IE window
  17.         If TypeName(GetOpenIEByURL.Document) = "HTMLDocument" Then
  18.             'check the URL
  19.             If InStr(GetOpenIEByURL.Document.url, i_URL) > 0 Then
  20.                 Call finditforme(i_URL)
  21.                 'I capture the outer frame
  22.                 Set IEframes = GetOpenIEByURL.Document.frames
  23.                 'I capture the inner frame
  24.                 Set IEframes = IEframes.Item(0)
  25.                 'now I want to capture the form and its elements and set them for submital
  26.                 IEframes(0).Document.Forms(0).SearchText.Value = hvid
  27.                 IEframes(0).Document.Forms(0).SearchWhat.selectedIndex = 1
  28.                 IEframes(0).Document.Forms(0).HVQS_ACTION.Value = 1
  29.                 IEframes(0).Document.Forms(0).submit
  30.                 flag = True
  31.                 Call finditforme(i_URL)
  32.                 Exit For
  33. ''            Else
  34. ''                MsgBox "Please login and try again"
  35.             End If
  36.         End If
  37.     Next
  38.     If Not flag Then
  39.         MsgBox "Please login and try again"
  40.         Call GetNewIE("http://some.website.com/frames.asp")
  41.     End If
  42.     Exit Function
  43. catchError:
  44.     MsgBox Err.Description
  45. End Function
  46.  
  47. Sub GetNewIE(iurl)
  48.     Dim objIE As Object
  49.     On Error GoTo error_handler
  50.     Set objIE = CreateObject("InternetExplorer.Application")
  51.         With objIE
  52.             .Navigate iurl
  53.             Do While .Busy: DoEvents: Loop
  54.             Do While .ReadyState <> 4: DoEvents: Loop
  55.             .Visible = True
  56.         End With
  57.     Set objIE = Nothing
  58.     Exit Sub
  59. error_handler:
  60.     MsgBox ("Unexpected Error, I'm quitting.")
  61.     objIE.Quit
  62.     Set objIE = Nothing
  63. End Sub
  64.  
  65.  
Jun 15 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Maurice Mertens | last post by:
Does anyone know how to get an auto-filling combobox on a form? When I add a combobox to a form I can set the DropDownStyle property to DropDownList. This will make the combobox auto-filling. But...
1
by: mikeybe | last post by:
Making a very simple library circulation database for a school project. I have a Patron Information table(patronID, first name, last name, phone) , an item information table (bookID, book title,...
2
by: Joanne Lewis | last post by:
I am having a great deal of difficulty with a form. Basically, I would like to enter an account # and have the account #, patient first name, and patient last name automatically fill. The form...
0
by: KelHemp | last post by:
Greetings, I've been using this site for lots of access help in the past, and it's very helpful! I have a new complexity for you all. Reworking a form to record 70-80 years of oil production on...
1
by: camphor | last post by:
hi, I need help with some code for an e-commerce site and am not sure which forum this question falls into but this is what I am after: the buyer goes through the shopping cart stage, he/she has...
2
by: mxdllc | last post by:
i would like to create an admin panel for my business. because i have 5 or 6 suppliers and to order i have to lookup which supplier it is then find the url, so to make things a little easier im going...
1
by: Captdreamer | last post by:
Hi there, As it will be very apparent in a moment, I am very new to Access and learning on the fly. (Much fun, but frustrating at the same time) I currently am trying to get a Combo Box that I...
3
by: Steve67 | last post by:
I didn't see a search feature in these forums, so I couldn't look up this question and I am sure it is a common questions. I am trying to auto fill some information on an form. Here is what I have...
2
by: Xaysana12345 | last post by:
Please help. I have been developing a financial database, now I have been in last bit to finish. i do not know much technical terms, but i am trying to explain what i need. so please be with me. ...
106
by: bonneylake | last post by:
Hey Everyone, Well i don't know if my question should be in javascript/ajax or coldfusion, i figure this is more of a coldfusion question. But if this is in the wrong section let me know an all...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 ...
0
muto222
php
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.