OutputTo and SendObject Methods, Snapshot Object Type Examples
The following example outputs a snapshot file to disk or embedded in a mail message depending on the value supplied in the intOutputTO argument. There are two global constants defined in the declarations section of the module that are used to specify the type of output desired. If the intOutputTO argument contains the constant conSaveSnapshotToDisk, then the file is saved using the location and file name supplied in the strPath argument. If the intOutputTO argument contains the constant conSaveSnapshotToMail, then the file is embedded in a mail message addressed to the name supplied in the strRecipName argument. The strName argument is the name of a Report object in the current database. The strPath argument is the full path and file name representing the snapshot file to be saved to disk.
Const conSaveSnapshotToDisk As Integer = 1
Const conSaveSnapshotToMail As Integer = 2
Sub OutputSnapshotFile(intOutputTO As Integer, _
strName As String, Optional strPath As String, _
Optional strRecipName As String)
Dim strOutputFormat As String
DoCmd.Hourglass True
strOutputFormat = "Snapshot Format"
Select Case intOutputTO
Case conSaveSnapshotToDisk
If Len(strPath) > 0 Then
DoCmd.OutputTo acOutputReport, _
strName, strOutputFormat, strPath
Else
DoCmd.Hourglass False
Exit Sub
End If
Case conSaveSnapshotToMail
If Len(strRecipName) > 0 Then
DoCmd.SendObject acSendReport, _
strName, strOutputFormat, strRecipName
Else
DoCmd.Hourglass False
Exit Sub
End If
Case Else
End Select
DoCmd.Hourglass False
End Sub