Originally Posted by
Paul_Hossler
...I hope someone can come up with a way to just 'read' the embedded file. I'd find that useful
My workwaround is to put the reference material into cells in a hidden worksheet, which is easily accessable to VBA
Paul
Hi Paul,
Hope I'm not misunderstanding... While this will not read the embedded object directly, would saving it temporarily help?
Adapted from: http://www.sqldrill.com/excel/progra...-filename.html
Option Explicit
Sub exa1()
Dim FSO As Object ' FileSystemObject
Dim fsoFol As Object ' Folder
Dim fsoStream As Object ' TextStream
Dim fsoFile As Object ' File
Dim myShell As Object
Dim sFilNam As String
Dim shp As Shape
Set FSO = CreateObject("Scripting.FileSystemObject")
Set fsoFol = FSO.GetFolder(ThisWorkbook.Path & "\")
If Not FSO.FolderExists(ThisWorkbook.Path & "\tempfol") Then
FSO.CreateFolder ThisWorkbook.Path & "\tempfol"
Else
sFilNam = Dir$(ThisWorkbook.Path & "\tempfol\*")
Do While Not sFilNam = vbNullString
Kill ThisWorkbook.Path & "\tempfol\" & sFilNam
sFilNam = Dir$
Loop
End If
Set shp = Sheet1.Shapes("Object 1")
shp.Copy
Set myShell = CreateObject("Shell.Application")
myShell.Namespace(CVar(ThisWorkbook.Path & "\tempfol\")).Self.InvokeVerb "Paste"
Set myShell = Nothing
Set fsoFile = FSO.GetFile(ThisWorkbook.Path & "\tempfol\" & Dir$(ThisWorkbook.Path & "\tempfol\*"))
Set fsoStream = fsoFile.OpenAsTextStream(ForReading)
Do While Not fsoStream.AtEndOfStream
'do whatever
Debug.Print fsoStream.ReadLine
Loop
fsoStream.Close
Set fsoFile = Nothing
Set fsoStream = Nothing
sFilNam = Dir$(ThisWorkbook.Path & "\tempfol\*")
Do While Not sFilNam = vbNullString
Kill ThisWorkbook.Path & "\tempfol\" & sFilNam
sFilNam = Dir$
Loop
FSO.DeleteFolder ThisWorkbook.Path & "\tempfol"
End Sub
Not well tested, but seems to work
Mark