Home >

How to extract and save Flash objects locally from within Microsoft Office documents

3. August 2008

If you ever received an office document with a flash object embedded in and want to extract it to run as a standalone application. Please execute following VBA code to simply extract embedded flash object in your file system.

Just open that office file, press alt+F11 and paste this following code. Execute it and save your embedded flash object in your file system:

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 

Comments

6/3/2010 8:45:35 AM #
Can I just say, this blog is what got me through the day today.  Every time I read it, I just get more and more excited about whats next.  Very refreshing blog and very refreshing ideas.  Im glad that I came across this when I did.  I love what youve got to say and the way you say it.

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading