How To Extract SWF Flash From MS Excel or MS Word?

電腦問題求助 有問必答 手提電腦, 電腦問答, 電腦維修及修理, computer, software, hardware, network, tips and more.
回覆文章
tech18
文章: 16
註冊時間: 2009-01-14, 08:41
來自: 上海

How To Extract SWF Flash From MS Excel or MS Word?

文章 tech18 »

"How To Extract SWF Flash From MS Excel or MS Word?"

While the SWF flash appears as an embedded file in Office Excel or Word, you might want to extract or retrieve the embedded SWF flash for your blog.

However, there is no intrinsic or built-in function to extract / retrieve embedded SWF Flash animation from Microsoft Office

document files. This is definitely true, that you won't able to find this wanted feature in Office 2007 as well!

So, how to extract SWF Flash animation from Office Excel?

A simple VBA program (a.k.a Visual Basic for Applications) can extract the embedded SWF Flash animation file in less than a minute or so.

The VBA / guide has been tested in Office 2003 Professional, and it should be working perfectly in any Office versions / editions too (e.g. the latest Office 2007), provided the Office system has installed the VBA components.

- Open a new Microsoft Excel document,

- Click the Tools menu, Marco, Visual Basic Editor. You can also press the "ALT+ F11" hotkey to bring up the VBA editor,

- While in MS Visual Basic editor, click the View Code icon on the upper-left panel,


- Copy the VBA program source code at below here and paste it onto the VBA source code editor,

- Press F5 to execute the VBA source code,

- An Open File dialog box prompts you to select the Office Excel document that embed the SWF Flash animation file,

- A message box appears shortly after the Excel file is selected, with a message that says where the extracted SWF Flash animation file is saved in local hard disk!

The extracted SWF Flash animation file ended with SWF file extension, and it can be open/play in a web browser with Shockwave Flash addon (e.g. Flash9e.ocx in IE7).

The VBA source code used to extract or retrieve SWF Flash animation files that embedded in Microsoft Office Excel or Word:

代碼: 選擇全部

Sub ExtractFlash()

Dim tmpFileName As String
Dim FileNumber As Integer
Dim myFileId As Long
Dim MyFileLen As Long
Dim myIndex As Long
Dim swfFileLen As Long
Dim i As Long
Dim swfArr() As Byte
Dim myArr() As Byte

tmpFileName = Application.GetOpenFilename("MS Office File (*.doc;*.xls), *.doc;*.xls", , "Open MS Office file")

If tmpFileName = "False" Then Exit Sub

myFileId = FreeFile

Open tmpFileName For Binary As #myFileId

MyFileLen = LOF(myFileId)

ReDim myArr(MyFileLen - 1)

Get myFileId, , myArr()

Close myFileId

Application.ScreenUpdating = False

i = 0

Do While i < MyFileLen

   If myArr(i) = &H46 Then

      If myArr(i + 1) = &H57 And myArr(i + 2) = &H53 Then

         swfFileLen = CLng(&H1000000) * myArr(i + 7) + CLng(&H10000) * myArr(i + 6) + CLng(&H100) * myArr(i + 5) + 

myArr(i + 4)

         ReDim swfArr(swfFileLen - 1)

         For myIndex = 0 To swfFileLen - 1
            swfArr(myIndex) = myArr(i + myIndex)
            Next myIndex
         Exit Do

      Else
            i = i + 3
      End If

   Else
        i = i + 1
   End If

Loop

myFileId = FreeFile

tmpFileName = Left(tmpFileName, Len(tmpFileName) - 4) & ".swf"

Open tmpFileName For Binary As #myFileId

Put #myFileId, , swfArr

Close myFileId

MsgBox "Save the extracted SWF Flash as [ " & tmpFileName & " ]"

End Sub
(Copyright © reserved by Walker.)

Hope this helps!

脸书 | 推特 | 電郵 | WhatsApp | 微博 | 微信 | 分享推荐按钮
回覆文章

回到「電腦資訊 電腦技術 有問必答 Computer Tech, Software, Hardware, Q&A」