PDA

View Full Version : [SOLVED:] VBA to fill up website form and upload file path via “Browse” buttton



fotodj
08-07-2017, 06:50 PM
Here is where I am stuck, I was able to write simple code to open IE window and fill data from cells B1, C1, D1 in few fields of web form,
code also clicks check boxes but form has a button "browse" which opens up my computer window and when I choose image it will show path to that image in the form, how can I input that path which I have in cell A1...

How can I input that path with VBA line?
Example of values in my excel file :
A1 - C:\Users\BrDariusz\Desktop\Texan_N22NA.jpg
B1 - N22NA
C1 - North American T-6G Texan
D1 - KNTU


Function FillInternetForm()



Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")

IE.Navigate "http://www.airport-data.com/aircraft/upload_quick.php?acid="

IE.Visible = True
While IE.busy
DoEvents
Wend

' ????? IE.document.All("picture").Value = ?????

IE.document.all("tail").Value = Sheets("Sheet1").Range("B1")
IE.document.all("desc").Value = Sheets("Sheet1").Range("C1")
IE.document.all("airport").Value = Sheets("Sheet1").Range("D1")
IE.document.all("terms").Click
IE.document.all("terms2").Click

End Function

D_Marcel
08-08-2017, 08:02 AM
I may be underestimating your request, but have you tried this?

Function FillInternetForm()


Dim IE As Object
Set IE = CreateObject("InternetExplorer.Application")

IE.Navigate "http://www.airport-data.com/aircraft/upload_quick.php?acid="

IE.Visible = True
While IE.busy
DoEvents
Wend

IE.document.All("picture").Value = Sheets("Sheet1").Range("A1")
IE.document.all("tail").Value = Sheets("Sheet1").Range("B1")
IE.document.all("desc").Value = Sheets("Sheet1").Range("C1")
IE.document.all("airport").Value = Sheets("Sheet1").Range("D1")
IE.document.all("terms").Click
IE.document.all("terms2").Click

End Function

fotodj
08-08-2017, 08:48 AM
No this will not work, it is not that simple, that field can be filled with path after "Browse" button is clicked and I need to choose picture for upload from my computer....

D_Marcel
08-08-2017, 09:02 AM
So you need this field ("picture") to be filled with the path of the file that you've selected in the Browser window?

fotodj
08-08-2017, 09:28 AM
Correct. I will have the path for correct picture in the excel file but I want to VBA code to automatically insert it with rest of the info from the row. And that is where I have a problem...