code it

Extract embeded Flash file from MS-Office documents

Found a nice code from web on how to extract .SWF file from a scrap file.
Steps on how to extract the embeded Flash File from MS-Office Documents.

1. Select and copy the embbeded flash file from the document.

2. Paste it in a folder. A scrap file will be created.

3. Paste the VBA code given below in Excel and run it. It will ask for the scrap file. Select it and click ok. The Flash will be extracted on the same path where the scrap file is.

Sub ExtractFlashFromScrapFile()

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(“Select Scrap File (*.*), *.*”, , “Select Scrap 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
MsgBox “&H46″

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

i = i + 3
End If

i = i + 1
End If


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


About these ads

December 26, 2010 - Posted by | Excel, VBA

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Get every new post delivered to your Inbox.

%d bloggers like this: