Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Extract embedded files from an Excel sheet to a directory

Status
Not open for further replies.

natureboy

Programmer
Jun 16, 2003
12
0
0
US
Hello,

I need a bit of help extracting a copy of an embedded OLEObject file from a sheet and saving it to a local directory. Here's the snippet of code to originally embed the PDF file:

Sub AttachDocumentation()

NumDocs = InputBox("How Many **Documentation** files do you wish to attach?")
Dim DocPath As String
i = 0
j = 4
MsgBox "Select the .PDF file you wish to attach as your Documentation."
ActiveSheet.Range("A3").Value = "Documentation Name"
Do Until NumDocs = 0
thefile = Application.GetOpenFilename("PDF Files, *.pdf")
ActiveSheet.Cells(j, 1) = "Documentation" & i & " is: " & thefile

ActiveSheet.OLEObjects.Add(Filename:= _
thefile, Link:= _
False, DisplayAsIcon:=True, IconFileName:= _
"C:\Program Files\Adobe\Acrobat 5.0\Reader\AcroRd32.exe", IconIndex:=0, _
IconLabel:= _
"Documentation" & i).Select
NumDocs = NumDocs - 1
i = i + 1
j = j + 1
Loop

End Sub

What method should I use to extract the file to a local directory for use with other operations? SaveToOle1File Method? I can't seem to find any example code anywhere. I'd like to preserve the original filename - not the the icon label.

Thanks in advance,
NatureBoy
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top