View Single Post
 
Old 12-17-2013, 06:43 AM
KSReynolds KSReynolds is offline Windows 7 32bit Office 2003
Novice
 
Join Date: Oct 2013
Posts: 7
KSReynolds is on a distinguished road
Default Save Word Files as OLE Bound Objects

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

Last edited by macropod; 12-17-2013 at 03:46 PM. Reason: Added code tags & formatting
Reply With Quote