Ask a question »

Inserting an animated gif in Excel

November 2015

In an Excel workbook, it is possible to insert an animated gif. The animation will work only when the image is inserted into a control. This can be done through Control Toolbox, Design mode and Microsoft Web Browser. VBA code is an integral part of inserting an animated gif in Excel. Once the procedure is completed, the active page of the Excel sheet must be changed and has to be visited again to check the animation is working. To insert the animated gif in other pages, the same VBA procedure can be utilised.

Inserting an animated gif in Excel

To insert an animated gif image in an Excel spreadsheet, you must insert the image into a control.

To insert the control:
  • Go to View > Toolbars > Control Toolbox
  • Activate Design mode
  • Choose the last button (the one with a hammer), then select Microsoft Web Browser
  • Draw a frame for the image
  • Disable Design mode and the toolbar
  • Paste the following code in the VBA editor:

Private Sub Worksheet_Activate()       
   WebBrowser1.Navigate "X:complete path image.GIF"       
End Sub
  • Change the active page of the spreadsheet, and then turn on the page containing the animation, to see the if it works.
  • To add other events, proceed in the same way each time adding a line to the above code, taking into account the control number assigned.

       WebBrowser2.Navigate "X:complete path image.GIF" 
  • To add other events on other pages, you must do the same by adding the VBA procedure on each page.

If the size does not fit the image, it must be corrected:
  • View > Toolbars > Control Toolbox
  • Active Design mode
  • Resize the frame and the parameters
  • Disable Design mode and the toolbar
For unlimited offline reading, you can download this article for free in PDF format:

See also

In the same category

Published by jak58. - Latest update by aakai1056
This document entitled « Inserting an animated gif in Excel » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.