VB 6.0 webbrowser control to automate File Input Value

Posted on 2005-05-11
Last Modified: 2013-12-25
I do have a webbrowser control in my VB form, while I have a file type input in my webpage. I already know the physical location of my file, and I would like the software to auto fill them.

Here is the html coding

<table V5DOTBL=true border="1">
<tr valign="top"><td width="144" bgcolor="#FF9FA9"><div align="right"><a href="javascript:alert('Click the browse button to select each file you wish to attach to this message.  You may send two attachments per message.')"><b><i><font size="2" face="Times New Roman">Attachment:</font></i></b></a></div></td><td width="555" bgcolor="#FF9FA9"><font size=-1>
<input type="file" name="%%File.48256d1000036f9a.02b1bfacb55094b448256d3b002b99d2.$Body.9.19C2">
<input type="file" name="%%File.48256d1000036f9a.02b1bfacb55094b448256d3b002b99d2.$Body.9.19E4"></font>

I tried the VB coding

Private Sub Command2_Click()
        WebBrowser1.Document.Forms(0).Elements("%%File.48256d1000036f9a.02b1bfacb55094b448256d3b002b99d2.$Body.9.19C2").Value = "C:\test.html"
End Sub

But seems like the value never been updated.
Please have a try on the test webpage

I visited this page but still couldn't get the clue.
Question by:cybeh
    LVL 10

    Expert Comment

    Hi, cybeh.

    I've had no success either.  Per the following EE posts, it's apparently not possible to do this for security reasons:

    Microsoft's page regarding Input File types:

    LVL 1

    Author Comment

    em....Seems like i need to request the user to add the file in manually......:(
    LVL 1

    Author Comment

    oh...or is there any possible way that, I already set focus to the input box, and make a simulation like the string is typing in by the keyboard? Hope you get what I mean. If that is possible, may i know how?
    Since the file location might be very long, it might be troublesome for the user to type in. So, as long as the user set a focus on the input box, by click on a button, the "C:\test.html" will be auto apear.

    LVL 10

    Accepted Solution

    If we could set a value to the input file element, this might be possible.  But to my knowledge there is no way to do this.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
    The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
    Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
    This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    14 Experts available now in Live!

    Get 1:1 Help Now