Problem printing to PDF

Dachande11

Registered User.
Local time
Today, 00:16
Joined
May 1, 2001
Messages
41
Hello I have been searching through this forum to find a way of exporting a report to a PDF file. I have found the answer and tried to get it to work but keep getting an error 2202 (you must install a printer before you print etc.).

I was wondering if anybody knew what I was doing wrong as I am a novice when it comes to VBA.

I have inserted the relevant code into the win.ini file, although I could not see a "[ports]" section as described in the posts I have viewed.

I have imported all of the modules from the defaultprt.mdb file.

I also added the extra bit of code into a new module and then used the code below on a 'On Click event'

Private Sub test_Click()
ChangeToAcrobat
ChangePdfFileName "test.pdf"
DoCmd.OpenReport "CBA_Data_Master_Cross", acViewNormal
ResetDefaultPrinter

End Sub

I hope I have explained this ok and I would appreciate any help.

Thanks

Mark
 
I may be mistaken, but this is not related to Access, but rather a general fault.

Have you tried printing to the PDF printer normally, say via Word?

Is it a local printer? Shared PDF Printers over a Lan wont work.

Hope this helps

Regards

Popolou

Update: Found this and i think it hits the nail on the head: Linky
 
Last edited:
Hello,

Thanks for your reply. I have run the report manually and printed it to a PDF file so I know that it does work manually, the link you gave me to the Ken Getz code is what I am using unsuccessfully at the moment. I really dont have a clue what I am doing wrong.

Thanks again

Mark
 
I have spent a day messing around with the Ken Getz code which deals with Win.ini and 5 different modules. This was a bit above me and I later found out that it might not be suitable for anything above Access 97.

So my solution is below.

I set the report to always print to PDF in My Documents.
I then in code print the report and then copy and rename it in a different folder.

The code is below. I also had to pause the code to allow the report to print before I copied it and have also included that module below which was created by Dev Ashish (thanks for that).

Private Sub test_Click()
Dim CICODE As String

CICODE = Me.SoldT

DoCmd.OpenReport "cba_data_master_cross", acViewNormal


Const cTIME = 5000 'in MilliSeconds
Call sSleep(cTIME)

Dim strFileOldName, strFileNewName As String
strFileOldName = "C:\Documents and Settings\szymkm\My Documents\CBA_Data_Master_Cross.pdf"
strFileNewName = "C:\Documents and Settings\szymkm\My Documents\" & CICODE & ".pdf"

FileCopy strFileOldName, strFileNewName
Kill strFileOldName

End Sub

Module

Option Compare Database

'***************** Code Start *******************
' This code was originally written by Dev Ashish.
' It is not to be altered or distributed,
' except as part of an application.
' You are free to use it in any application,
' provided the copyright notice is left unchanged.
'
' Code Courtesy of
' Dev Ashish
'
Private Declare Sub sapiSleep Lib "kernel32" _
Alias "Sleep" _
(ByVal dwMilliseconds As Long)

Sub sSleep(lngMilliSec As Long)
If lngMilliSec > 0 Then
Call sapiSleep(lngMilliSec)
End If
End Sub

Sub sTestSleep()
Const cTIME = 3000 'in MilliSeconds
Call sSleep(cTIME)
MsgBox "Before this Msgbox, I was asleep for " _
& cTIME & " Milliseconds."
End Sub
'***************** Code End *********************


I hope this helps

Mark
 

Users who are viewing this thread

Back
Top Bottom