Displaying An Animated Gif Image In Web Browser Control
The animated gif can be added in Excel sheet.
To insert the control:
1️⃣ Go to View > Toolbars > Control Toolbox
2️⃣ Activate Design mode
3️⃣ Choose the last button (hammer picture), then select "Microsoft Web Browser"
4️⃣ Draw a frame for the image (animated gif)
5️⃣ Disable Design mode and the toolbar
6️⃣ Paste the following code in the VBA editor:
1️⃣ Go to View > Toolbars > Control Toolbox
2️⃣ Activate Design mode
3️⃣ Choose the last button (hammer picture), then select "Microsoft Web Browser"
4️⃣ Draw a frame for the image (animated gif)
5️⃣ Disable Design mode and the toolbar
6️⃣ 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 Sub
WebBrowser1.Navigate "about:<html><body scroll='no'><img src=" & ThisWorkbook.Path & "\ani.gif> </img></body></html>"
End Sub
🔹 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
WebBrowser1.Navigate "about:<html><body scroll='no'><img src='http://http://www.animatedgif.net/animals/birds/birdtoon_e0.gif'> </img></body></html>"
End Sub
No comments:
Post a Comment