I know that this is not a preferred method, but I have inherited a database that requires this functionality for now. I need to save my Word documents in a function to Ole Bound Objects and can't find the vba code anywhere. I have a function that prints out the reports, but would like to modify to save as ole bounds. Three stars for anyone who can help, I'm googled out!
Code:
Public Function OpenWordDoc() As Boolean
OpenWordDoc = True
Dim objApp As Object
Dim objWord As Object
Dim strSQL As String
Dim NewCLS_Batch As DAO.Database
Dim rstLatentReports As DAO.Recordset
Dim IntI As Integer
Set NewCLS_Batch = CurrentDb
Set rstLatentReports = NewCLS_Batch.OpenRecordset("qryselectlatentreports")
rstLatentReports.MoveFirst
Set objWord = CreateObject("Word.Application")
objWord.Visible = False
If rstLatentReports.EOF Then Exit Function
IntI = 1
With rstLatentReports
Do Until .EOF
Set objDoc = objWord.Documents.Add()
Dim MyNewPathName As String
MyNewPathName = rstLatentReports.Fields("mypathname")
objWord.PrintOut , , , , , , , , , , , , MyNewPathName
On Error Resume Next
.MoveNext
IntI = IntI + 1
Loop
End With
rstLatentReports.Close
NewCLS_Batch.Close
End Function