If there is a file to download in IE browser, click the hyperlink of the file with the mouse, a toolbar will appear at the bottom of IE browser. There are two buttons on the toolbar: “Open”
“Save”.
If you click the “Save” button, the attachment will be saved to the system’s “Download” or “DownLoads” folder.
If you click the split button on the right, “Save As” will pop up. Choose Save As, and a Save File As dialog box will pop up. The user can enter the file name to execute the save.
I made a small tool called SaveIEFile.exe, which can be invoked in VBA or C# to automatically click save or save as.
For specific usage, please follow the steps below:
Step 1: Download the tool from the link below, and then unzip it to a folder without spaces.
SaveIEFile.zip
Step 2: Open a webpage in IE, which contains a The hyperlink to download the file, for example:
https://www.cnblogs.com/ryueifu-VBA/p/11018986. html
Step 3: Open a download link manually or with code to make a toolbar appear under the IE browser.
Step 4: Perform the following two processes in VBA:
Sub save()
Shell "E:\SaveIEFile.exe", vbHide
End Sub
Sub save as ()
Shell "E:\SaveIEFile.exe " & "C:\temp\ y.rar", vbHide
End Sub
If you are running the “save” process, you will see an automatic click The “Save” button on the toolbar.
If you run “Save As”, the attachments in the webpage will be saved to the specified file path, such as C:\ temp\y.rar
I have tested it on Win7 and Win10, no problem. The following is a dynamic picture
< /p>
Sub save()
Shell "E:\SaveIEFile.exe", vbHide
End Sub
Sub save as ()
Shell "E:\SaveIEFile.exe " & "C:\temp\ y.rar", vbHide
End Sub