Subject: Extract File From OLE Object
I used this code to extract an embedded object and save it to the user’s “My Documents” directory:
Sub Click(Source As Button)
Dim uidoc As notesuidocument
Dim doc As notesdocument
Dim EmbedObj As NotesEmbeddedObject
Dim handle As Variant
Dim MyDocumentsPath As Variant
Set w = New NotesUIWorkspace
Set uidoc = w.currentdocument
Set doc = uidoc.document
Set EmbedObj = doc.EmbeddedObjects(0)
Set handle = uidoc.GetObject(EmbedObj.Name)
Call EmbedObj.Activate(False)
MyDocumentsPath = Evaluate( “@RegQueryValue( ““HKEY_CURRENT_USER”” ;”“Software\Microsoft\Windows\CurrentVersion\Explorer\Shell Folders”“; ““Personal”” )”, doc )
If Left(EmbedObj.class, 11)=“Excel.Sheet” Then
'We are saving an excel spreadsheet.
Answer = Messagebox ( “Do you want to save this document to your computer’s hard drive?”, 4+32+0+0, “File Save”)
If Answer = 6 Then
'User clicked the “Yes” button.
Answer = “”
Answer = Inputbox(“Enter the filename you want to save the document as.”, “File Save”) + “.xls”
If Answer = “.xls” Then
'User didn’t enter a filename.
Messagebox “Document not saved.”
Exit Sub
End If
Call handle.SaveAs (MyDocumentsPath(0) + "" + Answer)
Messagebox “Document saved to your folder My Documents.”
Else
'User clicked the “No” button.
Messagebox “Document not saved.”
End If
Elseif Left(EmbedObj.class, 13)=“Word.Document” Then
'We are saving a Microsoft Word document.
Answer = Messagebox ( “Do you want to save this document to your computer’s hard drive?”, 4+32+0+0, “File Save”)
If Answer = 6 Then
'User clicked the “Yes” button.
Answer = “”
Answer = Inputbox(“Enter the filename you want to save the document as.”, “File Save”) + “.doc”
If Answer = “.doc” Then
'User didn’t enter a filename.
Messagebox “Document not saved.”
Exit Sub
End If
Call handle.SaveAs (MyDocumentsPath(0) + "" + Answer)
Messagebox “Document saved to your folder My Documents.”
Else
'User clicked the “No” button.
Messagebox “Document not saved.”
End If
Elseif Left(EmbedObj.class, 15) = “PowerPoint.Show” Then
'We are saving a Powerpoint presentation.
Answer = Messagebox ( “Do you want to save this document to your computer’s hard drive?”, 4+32+0+0, “File Save”)
If Answer = 6 Then
'User clicked the “Yes” button.
Answer = “”
Answer = Inputbox(“Enter the filename you want to save the document as.”, “File Save”) + “.ppt”
If Answer = “.ppt” Then
'User didn’t enter a filename.
Messagebox “Document not saved.”
Exit Sub
End If
'Call EmbedObj.Object.SaveAs (Answer)
Call handle.SaveAs (MyDocumentsPath(0) + "" + Answer)
'Call EmbedObj.Object.Application.Quit
Messagebox “Document saved to your folder My Documents.”
Else
'User clicked the “No” button.
Messagebox “Document not saved.”
End If
End If
End Sub