ACC97: How to Use Visual Basic for Applications to Export a Report in Snapshot Format (307184)



The information in this article applies to:

  • Microsoft Access 97

This article was previously published under Q307184
Moderate: Requires basic macro, coding, and interoperability skills.

SUMMARY

This article shows you how to use Visual Basic for Applications (VBA) code to export a Microsoft Access report in Snapshot format.

MORE INFORMATION

With Microsoft Access 97 Service Release 1 and Microsoft Office 97 Service Release 1, you can save a static picture of a Microsoft Access report in an external file format (*.snp). You can then make the report available to users who do not have Microsoft Access installed on their computers. For example, you can send the report in e-mail or copy it to a user's hard disk. The user has to have only Microsoft Snapshot Viewer to view the report.

If you have Microsoft Access 97 Service Release 1 or Microsoft Office 97 Service Release 1 on compact disc (CD), you can find Snapshot Viewer at the following location on the CD:

ValuPack\Access

Snpvw80.exe is a self-extracting file that installs Snapshot Viewer. Double-click the Valupk8.hlp file on your CD (located in the ValuPack folder) for information about how to install ValuPack features, including Snapshot Viewer.
For an example of how to use Visual Basic for Applications to export a Microsoft Access report in Snapshot format, follow these steps:

CAUTION: If you follow the steps in this example, you modify the sample database Northwind.mdb. You may want to back up the Northwind.mdb file and follow these steps on a copy of the database.

  1. Open the sample database Northwind.mdb.
  2. Create a new form in Design view.
  3. Make sure that the Control Wizards button in the toolbox is not turned on.
  4. Add a command button to the form.
  5. Right-click the command button, and then click Properties.
  6. Click the All tab.
  7. Change the Caption property to Export Report as SNP.
  8. Close the property sheet.
  9. Right-click the command button, and then click Build Event.
  10. In the Choose Builder dialog box, click Code Builder, and then click OK.
  11. Type or paste the following code:
        On Error Resume Next
    
        Dim stDocName As String
    
        stDocName = "Sales by Category"
        DoCmd.OutputTo acReport, stDocName, "SnapshotFormat(*.snp)", ""
    					
  12. On the File menu, click Close and Return to Microsoft Access to return to the form.
  13. View the form in Form view.
  14. Click the command button.
  15. In the Output To window, select the folder to which you want to save the report.
The report is saved as a Snapshot file. You can open the file without opening Microsoft Access if you have Snapshot Viewer installed.

Modification Type:MajorLast Reviewed:9/16/2003
Keywords:kbhowto KB307184