Link to home
Start Free TrialLog in
Avatar of kristofer
kristofer

asked on

webbrowser object

I have a filebox object loaded into an IHTMLInputFileElement called FileEl1.

The problem I have now is that I want the program to enter text into this filebox... When I try FileEl1.Value = MyValue nothing happens

Another thing I've tried is first FileEl1.Select and then I use Sendkeys() to enter text, this is however unrealiable, and on win2k I can't get it to work at all, it doesn't give an error msg it just doesn't work.

The last resort that actually worked on all is just Sendkeys()  right away and TAB yourself to the right box... this is however VERY unrealiable...

any ideas?
thx
Avatar of dredge
dredge

i think you first idea is on the right track, but it's not .value - i think it's something like .source or .filename ... but i don't remember what, off-hand.
Avatar of kristofer

ASKER

do you think you could find out? I can't find any of those you proposed under IHTMLInputFileElement in the MSDN Index...
this is the default behavior of the file input element.  because it is often used to provide a file location for uploading files from a webpage, for security reasons, you cant set its value, or otherwise you could put anything, and immediately invoke an upload script to grab the file you set as the default.

if you are simply trying to provide a convenience mechanism for your users, look for an alternative.  there is a workaround using IE and layers to hide the file input element, and use a plain text and button elements to give the "look" of supplying a default value, but, in fact, it is only a visual effect.
Oh ok, then that's why it doesn't work. Unfortunately I can't use your other suggestion because:
1. I don't administer the homepage
2. It's not purely a visual effect, the text has to go in the file box.

Well... I guess it's back to using Sendkeys("{TAB}...") =(

Shouldn't the FileEl1.Select work under win2k though?
Oh ok, then that's why it doesn't work. Unfortunately I can't use your other suggestion because:
1. I don't administer the homepage
2. It's not purely a visual effect, the text has to go in the file box.

Well... I guess it's back to using Sendkeys("{TAB}...") =(

Shouldn't the FileEl1.Select work under win2k though?
ASKER CERTIFIED SOLUTION
Avatar of AzraSound
AzraSound
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Richie_Simonetti
hearing...
.focus works, thanks a lot.

BTW. How did you know it had a .focus method?? It's not in MSDN under IHTMLInputFileElement...

just about every html element has a .focus method.  it should be in the MSDN under INPUT element, type=file