Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


Internet Explorer VB6

Posted on 2006-05-02
Medium Priority
Last Modified: 2008-03-04
hi everyone, i'm trying to auto send myself a file from internet explorer object from vB.

however, even so i can login in my account, i can't write the filename i wish to send.

i access the recipients email (mine) and it works, however, filename1 does not.

Here's my code:
          Set IE = CreateObject("InternetExplorer.Application")

            Do Until IE.readystate = 4
            IE.document.All.Item("recipient").Value = "WORKS FINE"
            IE.document.All.Item("filename1").Value = "this one does not..."

      And here is html code of that fraction of page:
            <td align="right">To:&nbsp;</td>
                  <td><input type="text" name="recipient" style="width:140px;" /><input type="button" onClick="newWindow('previous.php','window2');" value="previous" /></td>
                  <td align="right">File:&nbsp;</td>
                  <td><input type="file" name="filename1" /></td>
                  <td align="right" valign=top>Note:&nbsp;</td>
                  <td><textarea rows=2 cols=15 name=note></textarea></td>
                  <td><input type="submit" value="send" />

            it even submits, just that the file goes on blank...
            i think it hase something to do with it being of type file...
Question by:ogog
  • 4
  • 3
LVL 17

Expert Comment

by:Cem Türk
ID: 16591805

Expert Comment

ID: 16592112
To assign a value to a File Control in an HTML page is extremely forbidden for security purpose.

Just imagine, if you are allowed to do that, web sites would also be able to get any files on your computer silently by the same way.

The only way should be, get the hwnd of the IE Window, then post some key stroke messages to it.

Author Comment

ID: 16593590
junglerover77 can you show me how, i can increase points.

well, security causes trouble when you can't do the secure things you want to do YOURSELF! It's like buying a door that's so secure, that when you forget your keys inside, a truck has to break a wall.

This would ease my job... i've sent keystrokes before but to entire windows to automake corel draw actions. can you show me how to send them speciffically to ie windoW?
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!


Accepted Solution

junglerover77 earned 520 total points
ID: 16595699
After I tried to achieve this goal for 2 hours, I have to say that I was wrong. The API "PostMessage" can post a key stroke to any Input Controls in Normal windows applications, but not Internet Explorer. That's because the Input Controls, which exist in a HTML page in an IE window, don't have hWNDs.

The windows structure of Internet Explorer is:
IEFrame -> Shell DocObject View -> Internet Explorer_server
But because the window "Internet Explorer_server" is just an OLE container, it has no child windows. So......

You can use the following code to post a key to a textbox in another form without activate it:
Call PostMessage(Form2.Text1.hWnd, WM_CHAR, Asc("a"), 1)
But it's not compatible for IE.

So, the only way to achieve your goal might be activate the IE window, focus on the control, then Sendkeys ...... I know that's not good, but I do have no better idea. Sorry for that.


Author Comment

ID: 16621590
:( well... if that is the way, junglerover sure deserves the points scince he've showed so much effort.

Anyway could you just tell me how to login on this site: "http://jumk.de/notepad/"

 IE.document.All.Item("user").Value = "my name" -> this one is not working...
 IE.document.All.Item("log").Value = "my pass"

I'm tired of trying this... Can't get it to work...

Expert Comment

ID: 16621613
If you wanna access a control via the "All" collection, you must set its "id" property, not "name".

So, you can only do it this way:
    IE.Document.GetElementsByName("user")(0).Value = "my name"
    IE.Document.GetElementsByName("log")(0).Value = "my pass"

Author Comment

ID: 16621632
now i can't submit. I'm using:


as i always do...

Sorry, last time i bother you!!!!

Expert Comment

ID: 16623078
I just tested your code and it works well, and I don't know why it doesn't work on your computer.

Alternatively, you can try the following statement:

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
The System Center Operations Manager 2012, known as SCOM, is a part of the Microsoft system center product that provides the user with infrastructure monitoring and application performance monitoring. SCOM monitors:   Windows or UNIX/LinuxNetwo…
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…
Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.

580 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