vba error

davide128

Board Regular
Joined
May 12, 2010
Messages
58
I'm trying to extract a swf(flash) file from a word doc and getting this "compile error" method or data member not found.. The VBA is choking at this point . any ideas?

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

Excel Facts

Links? Where??
If Excel says you have links but you can't find them, go to Formulas, Name Manager. Look for old links to dead workbooks & delete.
The code from the page you linked to compiled and ran okay here, as did the single line you quoted. Can you post the complete contents of your code module here?

(Please use CODE tags - the # icon in the advanced editor toolbar.)
 
Upvote 0
Code:
Sub ExtractFlash()
    Dim tmpFileName As String, FileNumber As Integer
    Dim myFileId As Long
    Dim myArr() As Byte
    Dim i As Long
    Dim MyFileLen As Long, myIndex As Long
    Dim swfFileLen As Long
    Dim swfArr() As Byte
    tmpFileName = Application.GetOpenFilename("office File(*.doc;*.xls),*.doc;*.xls", _
                         , "Select Excel / Word 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 "SaveAs " & tmpFileName
End Sub

I think I'm missing a refernee or something cauase it doesn't seems to be finding the getopenfilename method...I just dont know how to add it
 
Upvote 0
You shouldn't need any additional references. Again, your code ran fine here.

You are running it in Excel, aren't you, and not Word?
 
Upvote 0
Because Word does not have a .GetOpenFileName method - that's only in Excel. The article does say that the code is for Excel.

If you want to run it in Word, you'd have to borrow the method from Excel, something like this:-
Code:
dim objexcel as object
set objexcel=createobject("excel.application")
tmpfilename=objexcel.getopenfilename... etc
(Uses late binding, so no additional references required.)
 
Upvote 0

Forum statistics

Threads
1,224,548
Messages
6,179,451
Members
452,915
Latest member
hannnahheileen

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top