vba 在工作表上插入动画 gif

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27132875/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 05:21:32  来源:igfitidea点击:

Insert animated gif on a worksheet

excelvba

提问by SMORF

I have an animated gif file.

我有一个动画 gif 文件。

How can I get this animation to appear on Sheet1 and then close when my macro is complete?

我怎样才能让这个动画出现在 Sheet1 上,然后在我的宏完成后关闭?

I tried adding the gif as a picture then adding a webbrowser command window and command button.

我尝试将 gif 添加为图片,然后添加 webbrowser 命令窗口和命令按钮。

I wrote the following command button code.

我写了以下命令按钮代码。

Private Sub CommandButton1_Click()
    WebBrowser1.Navigate1 ("C:\Users\smorfett\Desktop\progress.gif")
End Sub

I get

我得到

'Object doesn't support this property or method'

'对象不支持此属性或方法'

回答by SMORF

I found a solution ...

我找到了解决方案...

Private Sub CommandButton1_Click()

WebBrowser1.Navigate "C:\Users\smorfett\Desktop\progress.gif"

End Sub

回答by user11410866

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:

转到 View > Toolbars > Control Toolbox Activate Design mode 选择最后一个按钮(有锤子的那个),然后选择 Microsoft Web Browser 为图像绘制一个框架 禁用设计模式和工具栏 在 VBA 编辑器中粘贴以下代码:

Private Sub Worksheet_Activate() WebBrowser1.Navigate "X:complete path image.GIF" End Sub

Private Sub Worksheet_Activate() WebBrowser1.Navigate "X:complete path image.GIF" End Sub

Source: https://ccm.net/faq/1402-inserting-an-animated-gif-in-excel

来源:https: //ccm.net/faq/1402-inserting-an-animated-gif-in-excel