VBA Script to select the file and upload on IE

sbheeman

New Member
Joined
Jan 14, 2019
Messages
3
Hi All i am trying to create a script to upload a wallpaper after signing.
So far got through this after several attempts, your help is greatly appreciated.

Source:

HTML:
Upload

Upload

current code

Code:
Dim HTMLDoc As HTMLDocumentDim MyBrowser As InternetExplorer
 Sub VCW()


 Dim MyHTML_Element As IHTMLElement
 Dim MyURL As String
 On Error GoTo Err_Clear
 MyURL = "http://xxxxx"
 Set MyBrowser = New InternetExplorer
 MyBrowser.Silent = True
 MyBrowser.navigate MyURL
 MyBrowser.Visible = True
 Do
 Loop Until MyBrowser.readyState = READYSTATE_COMPLETE
 Set HTMLDoc = MyBrowser.document
 HTMLDoc.all.UserName.Value = "xxxx"
 HTMLDoc.all.Password.Value = "xxxxx"
 Application.SendKeys "~"


 // sign-in complete, need to proceed with upload after sign in.
    
Err_Clear:
 If Err <> 0 Then
 Err.Clear
 Resume Next
 End If
 End Sub
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
<form class="form-inline" method="post" enctype="multipart/form-data" action="/web/personalization/upload_wallpaper"><input type="file" name="file" accept="image/*"><button class="btn btn-primary" type="submit">Upload</button><input type="hidden" name="token" value="dfdfdsddssdsdf"></form>
<input type="file" name="file" accept="image/*">
<button class="btn btn-primary" type="submit">Upload</button>

HTML codes
 
Upvote 0
Code:
<form class="form-inline" method="post" enctype="multipart/form-data" action="/web/personalization/upload_wallpaper"><input type="file" name="file" accept="image/*"><button class="btn btn-primary" type="submit">Upload</button><input type="hidden" name="token" value="sdsdsds"></form>
<input type="file" name="file" accept="image/*">
<button class="btn btn-primary" type="submit">Upload</button>
 
Upvote 0
You can't upload a file through IE automation, it's a security issue so it is blocked.

You'll need to post the file directly using http - this is not trivial and we'd need far, far more information to be able to help you - and probably access to the actual form.
 
Upvote 0

Forum statistics

Threads
1,223,893
Messages
6,175,239
Members
452,621
Latest member
Laura_PinksBTHFT

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top