IE Automation Http Post Method

carpy1985

Board Regular
Joined
Nov 16, 2011
Messages
79
Hi Guys,

(Disclaimer: I can ONLY use Excel VBA to perform this task due to security restrictions in work)

Story So Far :):
I am trying to automate things in work and part of that requires me to log onto an FTP server and upload files. I can automate the log in via Excel VBA and navigate to the correct page and simulate pressing the upload button but then i cannot control the "Choose File To Upload" window that pops up to enter the file location and submit the form / upload the file.

A colleague has advised me that a much better method would be to look into HTTP Post Requests as they are quicker and less prone to going wrong. Sounds like the thing i need, but, i have spent hours trying to understand them and the info i have come across via Google is pretty sparse when it comes to doing this via Excel VBA...

Where i am now:
I have used a HTTP Header Inspector to look at what is being sent at each stage and have that data below to hopefully tap into someones superior knowledge!

I need the VBA to be able to:
o log in to the website using a username and password
o navigate to a specified folder and upload a file
(o and also maybe log out afterwards ready for the next time i need to upload a file)

The header details for the log in page look like this:
https://ftp.somesiteihavetologinto.com/FTPClient/Account/Login.htm
Header
Content-Type: application/x-www-form-urlencoded

Raw Data

username: blah123
password: abc123
usewtc: true

The header details for the upload page look like this:
https://ftp.somesiteihavetologinto.com/TestDataFeeds/
Header
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryxa7mgUU8Mu6riKG1


Raw Data
Content-Disposition: form-data; name="ftpupload"; filename="C:\Users\MyName\Desktop\OutlookTestFolder\Test_Doc_20130307.xlsx"
Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

I have seen a couple of examples in the forums that address POST via Excel but couldn't piece it together.

I am at my wits end now and any help would be appreciated!
 

Excel Facts

Return population for a City
If you have a list of cities in A2:A100, use Data, Geography. Then =A2.Population and copy down.

Forum statistics

Threads
1,214,865
Messages
6,121,988
Members
449,060
Latest member
mtsheetz

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top