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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
<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,224,820
Messages
6,181,162
Members
453,021
Latest member
Justyna P

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