Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

REPOST:How can I Print saved SNP files from code? 1

Status
Not open for further replies.

romnew

Programmer
Feb 27, 2002
44
ZA
Hullo Kchernak and everyone,
Kchernak, you wrote in your post, the same name as above, the following:
I spent some time looking through the snapview help files and ended up having to create a form with a snapshot control where I could manipulate the snapshot path property using code, and then cycle through the snp files in the folder to print the reports. Not sure its the fastest way to go, but I'm limited by the speed of the printer anyway, and I'm the only user of the application.
I am trying to do the same with no succes.
I use AccessXP.
This is what I am doing, but it boms out, error "NO OBJECt"
I have created a form with the snapshot viewer and a ref to an existing snp report in another folder, and which on open checks another folder for files. If present I check for snp files and then go over to change the SnapshotPath property of the file just identified.
Here is the code:
Dim folderspec As String, gstrFolderPath As String
Dim snpviewer As SnapshotViewer
gstrFolderPath = "C:\Rossair4"
folderspec = "C:\Rossair4"
Dim fso, f, fl, fc, s, t
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each fl In fc
s = s & fl.Name
s = s & "<BR>"
Next
If s = "" Then
Exit Sub
Else

For Each fl In fc
t = t & fl.Name
If Right(t, 3) = "snp" Then
MsgBox "OK"
**********Boms out here
Set snpviewer = ("snapshotviewer")

' Load the selected snapshot report into the snapshot viewer control.
snpviewer.SnapshotPath = gstrFolderPath & "\" & t.Text

snpviewer.PrintSnapshot True
If Err = 2502 Then
' No report currently displayed in the snapshot viewer control.
MsgBox "Please select a report to print."
Else
Exit Sub
End If

Else
If Right(t, 3) = "xls" Then
Exit Sub
End If
End If
Next
Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
The code boms out at ********
The error seems to be looking for a declaration to Snapshot.
PLEASE help!
Piet
 
Hullo JPS,
Yes, the snapshot viewer is referenced!
I have tried so many options in the meantime, but no go.
Thanks for the reply.
Piet
 
And what about this ?
Set snpviewer = CreateObject("SnapshotViewerControl.SnapshotViewer")

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
Hi PHV,
I have changed the code with your suggestion, but boms out with error:"Activex cannot create an object"
This cooky seems hard!
I am searching though.
Cheers
Piet
 
try this:
Dim snp As SnapshotViewer
Set snp = New SnapshotViewerControl.SnapshotViewer

if that doesn't work make sure you have the file snapview.ocx on your system

HTH
Peter
 
Hi Peter,
Problem solved! Thanks be to your reply above. Have a star.
The form on open now prints all the snapshot reports from the allocated folder.
Here is the final code:
Private Sub Form_Open(Cancel As Integer)
Dim folderspec As String, gstrFolderPath As String
Dim snp As SnapshotViewer
gstrFolderPath = "C:\Rossair4"
folderspec = "C:\Rossair4"

Dim fso, f, fl, fc, s, t
Set fso = CreateObject("Scripting.FileSystemObject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each fl In fc
s = s & fl.Name
s = s & "<BR>"
Next

If s = "" Then
Exit Sub
Else

DoCmd.SetWarnings False

For Each fl In fc
t = t & fl.Name

If Right(t, 3) = "snp" Then
FormattedMsgBox "Report copies are to be printed.@Ensure the printer is on and loaded with paper.@", "Snp Report Printing"
Set snp = New SnapshotViewerControl.SnapshotViewer
'Load the selected snapshot report into the snapshot viewer control.
Me!snp.SnapshotPath = gstrFolderPath & "\" & t

Me!snp.PrintSnapshot True
If Err = 2502 Then
'No report currently displayed in the snapshot viewer control.
MsgBox "Please select a report to print."
Else
End If

Else
If Right(t, 3) = "xls" Then
DoCmd.TransferSpreadsheet acImport, 8, "DepotReturnItemsPre", "C:\Rossair3\" & t, False, ""
DoCmd.OpenQuery "QryAppDepotReturnItems"
DoCmd.OpenQuery "QryDelete DepotReturnItemsPre"

End If

End If
fl.Delete
t = Null

Next
DoCmd.Close acForm, "FrmReportViewer"
End If
Exit_Command2_Click:
Exit Sub

Err_Command2_Click:
MsgBox Err.Description
Resume Exit_Command2_Click
End Sub
Thankyou again for every one replying to posts
Tek-tips most supportive site.
Piet
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top