![]() |
Upload a file to a web using VBA
There is a site on our company's INTRANET that I need to upload a file to.
This is a FORM that needs the fileName to be populated, but I have not been able to get it to accept fileName from any means I have tried. I have ALL of the other fields working and it is to the point all I need to do is manually select the file, but I need to automate this. I have been able to access the site, stuff all kinds of other info into the websites varables, but I have NOT been able to stuff the fileName to upload. Here is the code (including some failed attempts) to get the file name into the web page. First, I am opening the page and logging in with a userform ("fNTLogin") Code:
Here is the webpage html code that needs to recieve the filename: Enter Email Address:<br <input type=text size=25 name=email value=""<br<br Select File To Upload:<br <input type=file name=fileName<br Thanks Bruce |
Upload a file to a web using VBA
Typically the only way to assign the file on a HTML form file element is to
actually click the button and select the file. The input element's functionality is not exposed to scripting or automation for security reasons. If it were possible to set it programmatically (or by pre-populating the path in the page HTML) then it would be possible to grab files without folk knowing. I realize this is an intranet application, but I'm not sure there's any way to relax that security. Tim "Bruce" wrote in message ... There is a site on our company's INTRANET that I need to upload a file to. This is a FORM that needs the fileName to be populated, but I have not been able to get it to accept fileName from any means I have tried. I have ALL of the other fields working and it is to the point all I need to do is manually select the file, but I need to automate this. I have been able to access the site, stuff all kinds of other info into the websites varables, but I have NOT been able to stuff the fileName to upload. Here is the code (including some failed attempts) to get the file name into the web page. First, I am opening the page and logging in with a userform ("fNTLogin") Code:
Here is the webpage html code that needs to recieve the filename: Enter Email Address:<br <input type=text size=25 name=email value=""<br<br Select File To Upload:<br <input type=file name=fileName<br Thanks Bruce |
Upload a file to a web using VBA
Have you been able to enter you email address? The tag "Input" is an array You may be putting filename in the wrong index of the array. Indexing will alway start with 0 (which is item 1). I can't tell from your code how many Input tags are on your page. One thing that I've been able to open the webpage manually (this doesn't work when the page is called from VBa) and then enter the a string into the input box. I usually just put my name into the box I'm trying to located. Then use the developers tool on the IE explorer by typing F12. There is a search box in the developers tool where you can search for the string that you put into the box. -- joel ------------------------------------------------------------------------ joel's Profile: 229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170493 Microsoft Office Help |
Upload a file to a web using VBA
I have been able to populate email...
I think Tim is gonna be right, I have seen several other referances to that... I will try the array method and see if that works. I may have to try sendkey, if I can figure out how to place the curser in the right box... Thanks Bruce "joel" wrote in message ... Have you been able to enter you email address? The tag "Input" is an array You may be putting filename in the wrong index of the array. Indexing will alway start with 0 (which is item 1). I can't tell from your code how many Input tags are on your page. One thing that I've been able to open the webpage manually (this doesn't work when the page is called from VBa) and then enter the a string into the input box. I usually just put my name into the box I'm trying to located. Then use the developers tool on the IE explorer by typing F12. There is a search box in the developers tool where you can search for the string that you put into the box. -- joel ------------------------------------------------------------------------ joel's Profile: 229 View this thread: http://www.thecodecage.com/forumz/sh...d.php?t=170493 Microsoft Office Help |
All times are GMT +1. The time now is 09:41 AM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com