Reputation: 89
I am trying to load a .gif image in the webbrowser control of a userform. I can import the .gif from a normal path as seen in the Code1, but I want to navigate to embedded .gif which is "object 6". How do I do it? I tried Code2, but could not. Thank you
Code1:
Private Sub UserForm_Initialize()
Me.WebBrowser1.Navigate2 "C:\Pictures\Splash.gif"
End Sub
Code2
Private Sub UserForm_Initialize()
Me.WebBrowser1.Navigate2 OLEObjects("Object 6")
End Sub
Upvotes: 0
Views: 727
Reputation: 166181
If your gif is not too large you could try converting it to a data uri:
https://ezgif.com/image-to-datauri
Store the converted image as text in a worksheet cell, then you can do something like this:
Private Sub UserForm_Activate()
With Me.WebBrowser1
.Navigate "about:blank"
While .ReadyState <> 4 Or .Busy: DoEvents: Wend
.Document.body.innerhtml = Sheet4.Range("A1").Value
End With
End Sub
Tested and works for me.
Some info on datauri limits: Data protocol URL size limitations
Max you can store in a cell is 32k characters, but you could split a larger string over multiple cells.
Upvotes: 2