Besides watching Flash videos (FLV files), you should have seen or played some Flash animation game as well (SWF files, a.k.a. Shockwave flash).
And most of the time, you received SWF Flash animation in Microsoft Office document. Very likely, the SWF animation file is embedded in Office Excel.
The reason of embedding SWF animation file in Office document is probably that majority of users is running on Windows / MS Office, and MS Office can serve as a container to run or play the SWF file.
(If you received an un-embedded SWF file, you might able to open and play the SWF animation in web browser that installed with Shockwave Flash add-on)
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 could you do that in case you’re really wanted to do so? OK, here we go:
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.
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:
Credit of the VBA code given to a Chinese blogger called Emily.


And most of the time, you received SWF Flash animation in Microsoft Office document. Very likely, the SWF animation file is embedded in Office Excel.
The reason of embedding SWF animation file in Office document is probably that majority of users is running on Windows / MS Office, and MS Office can serve as a container to run or play the SWF file.
(If you received an un-embedded SWF file, you might able to open and play the SWF animation in web browser that installed with Shockwave Flash add-on)
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 could you do that in case you’re really wanted to do so? OK, here we go:
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
Credit of the VBA code given to a Chinese blogger called Emily.


Custom Search



2013 •
Bravo… excellent.. :)
Excellent!!!!!!!!!!!!!!!!
[...] inserting the compressed executable program file as an embedded object in Microsoft Excel / Word, the Exchange server attachment filtering system automatically “allow” the email [...]
Very fine work..
Great computer genius.
hi,
thanks very much.
can you please explain the logic also. don’t really understand the binary part & other parts in it. why is it required? can you please explain it. PLEASE…
thanks.
regards
Raghu
Thanks a lot for this works great
[...] time ago, I wrote a post about how to extract SWF (Shockwave Flash) that embedded in Microsoft Excel or Word document. That’s not about [...]
excelent ……………….
Thanks a lot for this works great
U are a genius!!! thx man
Great men, so helpfull
Alonso From Ecuador
Fantastic dude!
excellent code! this code was made in C++?
Thanks
Thiago from Brazil
ThX….A…….LooooooooT
DuDe…………………………VeRy…..NiCe
” KumCLilli “
Superb job…
This is gr8! Thanx a lot!
Wooow, very well, many thanks!!!
Thank you.
How would you go about embedding an SWF into a word document?
Which version of Word you’re interested on? I am using Word 2007 now.
@Matt, I have just published the guide of embedding SWF file into Word 2007.
[...] and have fun with the embedded Shockwave Flash game in no time. (See also previous post on how to extract or retrieve the embedded SWF file in Microsoft Word or Excel) I am not sure the Microsoft Word or Excel Viewer can playback the embedded Shockwave Flash game, [...]
Hi this is great VB work and very impressive indeed. I am trying to stop the embedded flash from running in Word on our network do you know a way of doing this?
Paul
Cool
Nice code ….
working fine.
Thnks
wow thats marvellous
i have bin searching something to do this from ages
thx a a lot n keep up the good work.
It works! Thanks.
Hi, I have problem viewing the swf file in m. word 2007. The swf box appear but it doesn’t move. Can I know what happened?
Thanks.
Excellent!
I have been searching around for the solution, and this just works!
A simple, clear and easy to understand step-by-step guide!
great !!! thts what I was looking for since a long period of time…….. really cool…………..
Ευχαριστώ!
Thank you!
Great job & thanks for sharing.
Regards.
Amazing. It works……
Excel-went shock… with a wave & a flash it was out. Wow!
Many thanks. Season’s Greetings.
Thanks a lot!!!
Awesome dude… You save us from going insane in the office.
Merci beaucoup. C’est exactement ce qu’il me fallait !
great…!
work perfectly….!
thanks a lot….
Thank you! It works like a shot!
AWESOME, man, thanks!
I don’t have MS Office installed where i want to play this – open office doesn’t play them :(.
So it’s always better to have it out in SWF itself!
Great! works nice.
Note: to use this in Office 2007:
Click the Microsoft Office Button , and then click Excel Options.
In the Popular category, under Top options for working with Excel, select the Show Developer tab in the Ribbon check box, and then click OK.
now the Developer toolbar appears, click it then click “Visual Basic” icon, then continue the above steps.
Thanks for Emily :)
Its giving out of memory error at the below point
ReDim swfArr(swfFileLen – 1)
using vb6.3
Thank you!
This is great!
Very good job!
Just modified it a bit and can extract SWFs from any type of file. Any idea how to modify it to extract more than one embedded SWF?
Thank you.
It’s just what I needed.
Bravo.
error is coming:
Compile error
method or data member not found
Excellent work!!!!
really very helpful!!!
Thanx a Ton!!!
Is &H57 and &H53 the header of the swf file format?
I was hoping to extract different file types that are embedded OLE’s as well – but am not sure how to identify them.
Also, what does the &H46 indicate?
Jay,
Not sure if this will go through….
It’s rare to have multiple flash files in an office file, but this should get them all…
Public Sub ExtractEmbed() 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 Dim OutCount As Integer 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 OutCount = OutCount + 1 myFileId = FreeFile swfFileName = Left(tmpFileName, Len(tmpFileName) - 4) & "_" & OutCount & ".swf" Open swfFileName For Binary As #myFileId Put #myFileId, , swfArr Close myFileId 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 as [ " & tmpFileName & " ]" End SubGreat code, thank you very much.
You may deserve to get the red capsule.
Great job,
Also, useful in the new Adobe flash file exploits using doc files.
Excellent – what a time-saver!
I had a swf in a ppt slide so I simply copied/pasted the object to an xls file, followed the instructions above with the new xls file and voila!
getting “method or data member not found” error …:(
please help me
When it saves as a .swf it saves with 0kb and when I try to open it in another program it doesn’t play. Any suggestions?
Thanks
I used to have a program that removed Flash from Powerpoint, but now it doesn’t work in Windows 7.
Any chance you could alter this to make it function in powerpoint?
Awesome coding…
Loved it..
:-)