VBA:IE-How to assign pathname to file input tag without popup file upload form?

后端 未结 3 791
傲寒
傲寒 2020-11-30 13:27

I am currently doing automaiton for file uploading

Below is HTML tag for input file tag:

 

        
3条回答
  •  悲&欢浪女
    2020-11-30 14:16

    As setting the value of a file input element is disabled due to security reasons, the "send keys" method seems to be the only option for automating file uploads using the IE API.

    I just stumbled over the same problem that the code after the Click does not seem to be executed - that is, unless the dialog is closed. This indicates that the Click method is blocking, making it impossible to interact with the dialog from within the macro.

    I could solve that by using a different method to open the dialog: by setting the focus to the file element with Focus, and sending the space key with SendKeys.

    In your case, replace

    filee.Click
    

    with

    filee.Focus
    SendKeys " "
    

提交回复
热议问题