A
Ayala
Hi, I need to send to Word a Report including about 6 sub
reports.
For sending the data I'm using bookmarks, but I don't know
how to send the whole subreport...
Also is there a better way of doing this instead of using
bookmarks?? I first create a word template with the
bookmarks, then open the report in access and then send
the data to word. this is my code (summary)
Private Sub cmdSendToWord_Click()
On Error GoTo Err_cmdSendToWord_Click
Dim strSQL As String
strSQL = "GenDataID Like " & Me.GenDataID
DoCmd.OpenReport "rptGeneralData", acViewPreview, , strSQL
Dim myObject As Word.Application
Dim strInitDir As String
Dim strPath As String
strInitDir = "I:\Access Dbases\Service"
strPath = FileOpen(strInitDir)
Set myObject = New Word.Application
myObject.Visible = True
myObject.Documents.Open strPath
myObject.Activate
Dim strPasar As String
strPasar = IIf(IsNull(Reports!rptGeneralData!RptFor), " ",
Reports!rptGeneralData!RptFor)
myObject.ActiveDocument.Bookmarks("RptFor").Range. _
InsertAfter strPasar
strPasar = IIf(IsNull(Reports!rptGeneralData!
Product), " ", Reports!rptGeneralData!Product)
myObject.ActiveDocument.Bookmarks("Product").Range. _
InsertAfter strPasar
strPasar = IIf(IsNull(Reports!rptGeneralData!Plant), " ",
Reports!rptGeneralData!Plant)
myObject.ActiveDocument.Bookmarks("Plant").Range. _
InsertAfter strPasar
strPasar = IIf(IsNull(Reports!rptGeneralData!
Customer), " ", Reports!rptGeneralData!Customer)
myObject.ActiveDocument.Bookmarks("Customer").Range. _
InsertAfter strPasar
Set myObject = Nothing
Exit_cmdSendToWord_Click:
Exit Sub
Err_cmdSendToWord_Click:
MsgBox Err.Description
Resume Exit_cmdSendToWord_Click
End Sub
reports.
For sending the data I'm using bookmarks, but I don't know
how to send the whole subreport...
Also is there a better way of doing this instead of using
bookmarks?? I first create a word template with the
bookmarks, then open the report in access and then send
the data to word. this is my code (summary)
Private Sub cmdSendToWord_Click()
On Error GoTo Err_cmdSendToWord_Click
Dim strSQL As String
strSQL = "GenDataID Like " & Me.GenDataID
DoCmd.OpenReport "rptGeneralData", acViewPreview, , strSQL
Dim myObject As Word.Application
Dim strInitDir As String
Dim strPath As String
strInitDir = "I:\Access Dbases\Service"
strPath = FileOpen(strInitDir)
Set myObject = New Word.Application
myObject.Visible = True
myObject.Documents.Open strPath
myObject.Activate
Dim strPasar As String
strPasar = IIf(IsNull(Reports!rptGeneralData!RptFor), " ",
Reports!rptGeneralData!RptFor)
myObject.ActiveDocument.Bookmarks("RptFor").Range. _
InsertAfter strPasar
strPasar = IIf(IsNull(Reports!rptGeneralData!
Product), " ", Reports!rptGeneralData!Product)
myObject.ActiveDocument.Bookmarks("Product").Range. _
InsertAfter strPasar
strPasar = IIf(IsNull(Reports!rptGeneralData!Plant), " ",
Reports!rptGeneralData!Plant)
myObject.ActiveDocument.Bookmarks("Plant").Range. _
InsertAfter strPasar
strPasar = IIf(IsNull(Reports!rptGeneralData!
Customer), " ", Reports!rptGeneralData!Customer)
myObject.ActiveDocument.Bookmarks("Customer").Range. _
InsertAfter strPasar
Set myObject = Nothing
Exit_cmdSendToWord_Click:
Exit Sub
Err_cmdSendToWord_Click:
MsgBox Err.Description
Resume Exit_cmdSendToWord_Click
End Sub