|
手动插入FLASH到EXCEL操作比较烦琐,且容易出错.
以下这段代码简化了操作,只是运行完毕后,FLASH并不会自动播放,需要手工点击 退出设计模式 FLASH才会播放.
因无法用VBA代码控制自动退出设计模式,那位大大有空再研究一下,帮忙写一个ADDINS出来.
Sub InsertSWF()
Dim Fp
Dim Swf As String
Fp = Application.GetOpenFilename("Flash file,*.swf", , "Select Flash Movie", , False)
If Fp = False Then Exit Sub
ActiveSheet.OLEObjects.Add(ClassType:="ShockwaveFlash.ShockwaveFlash.9", _
Link:=False, DisplayAsIcon:=False, Left:=20, Top:=20, Width:= _
450, Height:=300).Select
Swf = Selection.Name
ActiveSheet.OLEObjects(Swf).Object.EmbedMovie = True
ActiveSheet.OLEObjects(Swf).Object.Menu = False
ActiveSheet.OLEObjects(Swf).Object.Movie = Fp
Range("D8").Select
Application.CommandBars("Exit Design Mode").Visible = True
Application.CommandBars("Exit Design Mode").Controls(1).Execute
End Sub |
|