Hi does anyone have any ideas about how to do this?
I have some code that I have been testing with but
it fails when I try to add the document to the
recordset, ANY help would be greatly appreciated.
Best regards // Greger Hagstr?m
Code follows:
Private Sub Command1_Click()
'---------INITIATE---------------------------------------------------
Dim Cmd As ADODB.Command
Dim Rs As ADODB.Recordset
Dim Con As ADODB.Connection
Dim Doc As Word.Document
'Dim Doc As Object
Set Cmd = New ADODB.Command
Set Rs = New ADODB.Recordset
Set Con = New ADODB.Connection
Set Doc = New Word.Document
'--------OPEN---------------------------------------------------
'Con.Provider = "Microsoft.Jet.OLEDB.4.0"
Con.Provider = "sqloledb"
Con.ConnectionString = "server=trainsql;Initial
Catalog=tmpCMDB_Extract;uid=sa;pwd=2l82go"
'Con.DefaultDatabase = "tmpCMDB_Extract"
Con.Open
'Con.Open "C:\Documents and Settings\qragrha\My Documents\Copy of
OLE-Object.mdb", "admin", ""
Set Doc = Word.Documents.Open("othello.doc")
'--------MAIN--------------------------------
'Rs.Open " SELECT tbl_Doc.Doc, tbl_Doc.Name FROM tbl_Doc ", Con,
adOpenKeyset, adLockOptimistic
Rs.Open " SELECT * FROM D_Documents ", Con, adOpenKeyset,
adLockOptimistic
'Debug.Print Rs.Fields("DOC").Value
'(auto)D_ID, C_ID, D_Name, D_Family, D_OLE
On Error Resume Next
Rs.AddNew
Rs!C_ID = "1"
Rs!D_name = "Testing docs"
Rs!d_family = "Information"
Rs!D_OLE = Doc
Rs.Update
Rs.Close
Rs.Open " SELECT tbl_Doc.Doc, tbl_Doc.Name FROM tbl_Doc ", Con,
adOpenKeyset, adLockOptimistic
While Not (Rs.EOF)
With Rs.Fields
Debug.Print .Item("Doc")
Set Doc = .Item("Doc").GetChunk(5000000)
End With
Rs.MoveNext
Wend
Doc.SaveAs "c:\mittDokument.doc"
Doc.Save
Rs.Close
'--------CLEAN----------------------------------------------------
Set Cmd = Nothing
Set Rs = Nothing
Set Con = Nothing
End Sub