Export OLE embedded documents from accesss to Office Files

Z

Zvi

I have the database on access 2000 / SQL server.
A table have columnd with embedded office (column Word, and Column Excell)
files.
I want to export all documents to files

I do not want to do it manually, there is about 600 Documents

please, help me.
 
J

John Nurick

I don't know enough about SQL Server to be entirely confident about
this, but here goes:

1) if the Office documents are stored as embedded objects, the simplest
approach seems to be bind a form to the table and automate a
BoundObjectFrame control; see http://support.microsoft.com/?id=132003
for sample code.

2) if the SQL Server columns simply store the contents of the Office
files (i.e. without the OLE packaging), open a recordset on the table
and use GetChunk() to extract the contents into a variable, then write
it to disk.
 
J

John Nurick

I can't find an example, but this snippet shows the general idea: again
you have to automate a form with a BoundObjectFrame control on it (here
named Ole1).

Dim oXL As Object
Dim strFileSpec as String

'Filename:
strFileSpec = "C:\Folder\File.xls"

'Activate the embedded document in an instance of Excel
Me.Ole1.Action = acOLEActivate
'get hold of the instance - assumes that there is only the one
'Instance of Excel running
Set oXL = GetObject(, "Excel.Application")

'Save the document
oXL.Workbooks(1).SaveAs strFileSpec
'Close it, leaving Excel running ready to process the next record
oXL.Workbooks(1).Close False
'Or close Excel if you are just exporting one document
'oXL.Quit


You can use the same approach with Word as an alternative to the
copy-and-paste in the Microsoft knowledgebase article.
 
T

Tony

Isn't there a way to do this programmatically without using the
OleBoundControl?

Using automation will work I believe for Office applications or other apps
which register with the OLE server, but I have had no luck with automation
and Packages because the .Object method of the OleBoundControl does not work.

The OleBoundControl seems to be able to properly identify and process all
types of embedded documents, including packages. I am thinking that there
has to be a way for us to do what Microsoft's OleBoundControl is doing so
that we too can identify what is in the OLE fields and process it accordingly.

Thanks
 
J

John Nurick

It has to be possible in principle, but AFAIK the details of the
packaging are not publicly documented. Stephen Lebans has done some work
in relation to jpegs which may be relevant: see
http://www.lebans.com/loadsavejpeg.htm.

Having to use the BoundObjectFrame is one of the reasons many people
avoid embedding documents in OLE fields: usually it's simpler to leave
the documents in disk files and just store the filespecs, or to store
the contents of the file in the database (as opposed to a packaged OLE
object containing the file).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top