Displaying An Animated Gif Image In Web Browser Control
The animated gif can be added in Excel sheet.
This can be done through Control Toolbox, Design Mode and “Microsoft Web Browser” Control.
To insert the control:
- Go to View > Toolbars > Control Toolbox
- Activate Design mode
- Choose the last button (hammer picture), then select "Microsoft Web Browser"
- Draw a frame for the image (animated gif)
- Disable Design mode and the toolbar
- Paste the following code in the VBA editor:
Private Sub Worksheet_Activate()
WebBrowser1.Navigate "about:<html><body scroll='no'><img src=" & ThisWorkbook.Path & "\ani.gif> </img></body></html>"
End SubWebBrowser1.Navigate "about:<html><body scroll='no'><img src=" & ThisWorkbook.Path & "\ani.gif> </img></body></html>"
We need to construct a image file path as correctly.So you need something like this:
WebBrowser1.Navigate "about:<html><body scroll='no'><img src=' C:\animated.gif '> </img></body></html>"
Change the active sheet of the workbook, and then turn on the sheet containing the animation, to see if it works.
The animated gif image can be added from any web address.For this,the following code can be used :
Private Sub Worksheet_Activate() WebBrowser1.Navigate "about:<html><body scroll='no'><img src='http://http://www.animatedgif.net/animals/birds/birdtoon_e0.gif'> </img></body></html>"
End Sub
End Sub