Internet Explorer VB6

Posted on 2006-05-02
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
    LVL 17

    Expert Comment

    LVL 6

    Expert Comment

    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.
    LVL 1

    Author Comment

    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?
    LVL 6

    Accepted Solution

    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.

    LVL 1

    Author Comment

    :( 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: ""

     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...
    LVL 6

    Expert Comment

    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"
    LVL 1

    Author Comment

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


    as i always do...

    Sorry, last time i bother you!!!!
    LVL 6

    Expert Comment

    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

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
    This collection of functions covers all the normal rounding methods of just about any numeric value.
    Viewers will learn how to maximize accessibility options in an Excel workbook for users with accessibility issues.
    The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

    729 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

    20 Experts available now in Live!

    Get 1:1 Help Now