Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using VBA to post a form and upload file to a website.. 1

Status
Not open for further replies.

mmorancbt

IS-IT--Management
Nov 11, 2002
367
US
Version info: Access 2003 or 2000; OS: XP Pro

I have an Access database that creates a .csv file from some SQL data. This file is then uploaded from my client to a vendor's website.

The process now is to create the file, open a browser, logon to the vendor's site, get to the upload form page, select the file that has been created, and then submit the form.

I want to, from within Access, logon to their website and then post to the required form with the current data file selected.

My biggest question is how to logon to the site and main that session open.

Can I, create an Internet Explorer object, use it to post to the logon form, maintain that Internet Explorer object and then use it to submit to the upload form with the required paramters?

Any code samples for this type of thing?

Thanks.

Matthew Moran
 
This is a workaround I came up with to help automate the process of running some ebay auctions. It requires babysitting and your code will need to be modified each time the web page is changed. It can be helpful though.

Of course you'll have to take my example and modify it to your application.

For this to work, the browser window must be visible and have "focus" (if that's the right word).

Code:
Sub main()
'requires a reference to "Microsoft Internet Controls"

Const webTab = vbTab
Const webShiftTab = "+" & vbTab
Const webSpaceBar = " "

Dim oIE As New SHDocVw.InternetExplorer
Dim sSearchTerm As String
Dim sURL As String

sSearchTerm = "programically fill out web form"

sURL = "[URL unfurl="true"]http://www.yahoo.com/"[/URL]

'open a new, visible IE window
Set oIE = New SHDocVw.InternetExplorer
oIE.Visible = True

'go to desired page - Yahoo in this case
oIE.Navigate sURL

'wait for page to finish loading
Do Until oIE.ReadyState = READYSTATE_COMPLETE
  DoEvents
Loop

'you can navigate through various tab-stops in the
'web page by using the SendKeys function to send
'a Tab or ShiftTab to the IE window.  Textboxes can
'also be filled out using SendKeys.  CommandButtons
'may be clicked by sending a blank space.
SendKeys sSearchTerm
SendKeys webTab
SendKeys webSpaceBar

MsgBox "waiting to close IE"

'close IE and release oIE object memory
oIE.Quit
Set oIE = Nothing

End Sub
 
BTW, there may be an easier and more reliable way for you to do this, especially if you have the cooperation of the vendor.
 
jm314,

I need to do something very much the same. I cut/pasted your example into the click event of a command button.
When I compile the program (Access 2000 with a reference to the Microsoft Internet Control) I get an error message "User-defined type not defined highlighting the
"Dim oIE As New SHDocVw.InternetExplorer" line.
Can you give me some information on what I have to do to get the SHDocVw in it?

Thanks, Joe
 
Hi jsink,

You need to add a reference (under Tools > References) to "Microsoft Internet Controls"

Enjoy,
Tony

--------------------------------------------------------------------------------------------
We want to help you; help us to do it by reading this: Before you ask a question.
Excel VBA Training and more Help at VBAExpress[
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top