VBA to open and print snapshot files

robburton

Registered User.
Local time
Today, 15:43
Joined
Apr 15, 2009
Messages
10
I could be missing something really obvious here, but I can't see it!!

I have a series of reports that I output from access to file in .snp format, however there are certain times of the day and night when I also need to submit these reports to a printer. The only solution I can think of, would be to assign a printer to the report and just open it, however due to the runtime of the report, I would prefer to output to file, and then just print the file.

I can't seem to find much on handling snapshot files through vba, and would appreciate some help.
 
Hi,

I wrote the following code to output a snapshot file type to my H Drive:

=========
BEGIN CODE
=========

DoCmd.OutputTo acReport, "rptDDLetterRunDGS", "SnapshotFormat(*.snp)", "H:\John Lee\rptDDLetterRunDGS.snp", False, ""

=========
END CODE
=========

It works fine for me, all you have to do is change the following to your requirements:

"rptDDLetterRunDGS", to whatever your report name is

"H:\John Lee\rptDDLetterRunDGS.snp", to the location you want and of course the report name

I hope this helps.

John
 
Thanks for your reply, I think I have not explained myself clearly. I have managed to output the files in .snp format, what I now need to be able to do, is to be able to open the .snp file and/or print it using vba. Sounds a bit long winded I know, my reasoning is that to output the access report as a .rtf file, looses all of the graphical formating, whereas outputting the .snp file retains this, and my users will need the facility to print the reports from file as they require after I have created the document.
 
SendObject Method

See AlsoApplies ToExampleSpecifics
The SendObject method carries out the SendObject action in Visual Basic.
expression.SendObject(ObjectType, ObjectName, OutputFormat, To, Cc, Bcc, Subject, MessageText, EditMessage, TemplateFile)
expression Required. An expression that returns one of the objects in the Applies To list.
ObjectType Optional AcSendObjectType.
AcSendObjectType can be one of these AcSendObjectType constants.acSendDataAccessPageacSendFormacSendModuleacSendNoObject defaultacSendQueryacSendReportacSendTable

ObjectName Optional Variant. A string expression that's the valid name of an object of the type selected by the objecttype argument. If you want to include the active object in the mail message, specify the object's type with the objecttype argument and leave this argument blank. If you leave both the objecttype and objectname arguments blank (the default constant, acSendNoObject, is assumed for the objecttype argument), Microsoft Access sends a message to the electronic mail application without an included database object. If you run Visual Basic code containing the SendObject method in a library database, Microsoft Access looks for the object with this name first in the library database, then in the current database.
OutputFormat Optional Variant.
To Optional Variant. A string expression that lists the recipients whose names you want to put on the To line in the mail message. Separate the recipient names you specify in this argument and in the cc and bcc arguments with a semicolon (;) or with the list separator set on the Number tab of the Regional Settings Properties dialog box in Windows Control Panel. If the recipient names aren't recognized by the mail application, the message isn't sent and an error occurs. If you leave this argument blank, Microsoft Access prompts you for the recipients.
Cc Optional Variant. A string expression that lists the recipients whose names you want to put on the Cc line in the mail message. If you leave this argument blank, the Cc line in the mail message is blank.
Bcc Optional Variant. A string expression that lists the recipients whose names you want to put on the Bcc line in the mail message. If you leave this argument blank, the Bcc line in the mail message is blank.
Subject Optional Variant. A string expression containing the text you want to put on the Subject line in the mail message. If you leave this argument blank, the Subject line in the mail message is blank.
MessageText Optional Variant. A string expression containing the text you want to include in the body of the mail message, after the object. If you leave this argument blank, the object is all that's included in the body of the mail message.
EditMessage Optional Variant. Use True (–1) to open the electronic mail application immediately with the message loaded, so the message can be edited. Use False (0) to send the message without editing it. If you leave this argument blank, the default (True) is assumed.
TemplateFile Optional Variant. A string expression that's the full name, including the path, of the file you want to use as a template for an HTML file.
Remarks

For more information on how the action and its arguments work, see the action topic.
Modules can be sent only in MS-DOS Text format, so if you specify acSendModule for the objecttype argument, you must specify acFormatTXT for the outputformat argument.
To send a snapshot, set the ObjectType argument to acSendReport and the OutputFormat argument to acFormatSNP.
You can leave an optional argument blank in the middle of the syntax, but you must include the argument's comma. If you leave a trailing argument blank, don't use a comma following the last argument you specify.
Example

The following example includes the Employees table in a mail message in Microsoft Excel format and specifies To, Cc, and Subject lines in the mail message. The mail message is sent immediately, without editing.
DoCmd.SendObject acSendTable, "Employees", acFormatXLS, _ "Nancy Davolio; Andrew Fuller", "Joan Weber", , _ "Current Spreadsheet of Employees", , False
 
I'm not sure I understand the relevance of this to my issue, I think this would relate to the ability to send a document/file to someone or somewhere via mail, the issue I have is not knowing how to open and print a specific type of file using vba in access.

If I've missed the point completely please expalin!!
 
Hi,

Apologies for taking so long to reply, been away. If all you want to do is print a report when you need it, why don't you use accesses print features.

For instance I have a reports switchboard and in this switchboard I have a number of reports that I want to print either daily or periodically. Using accesses switchboard features, when a particular button is clicked the report is printed to my default printer. This enables anyone using my database to print reports as and when they want.

behind each report is a query, that has criteria that determines what is printed in the report.

I don't understand why you would want to export the report as a snapshot and then use access to print it using VBA. It is far easier using accesses own abilities, unless I'm missing the boat completely, then I apologise.

John
 

Users who are viewing this thread

Back
Top Bottom