I have used CutePDF and Lebans code since 2004 successfully, even when the client doesn't allow installing dll's. As Hans stated, you need only put the dll's in the same directory as the mdb/mde. Both have been very flexible and allowed a lot of customization with minimal programming required.
Ken
Is it possible to... (PDF)
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Is it possible to... (PDF)
Just had to try using the DLLs :)
Still getting the Save dialogue box, but I've been looking over the same code too much & now I can't see anything properly
Here's what I'm using;
Anything obvious I'm doing (or not doing) wrong?
Still getting the Save dialogue box, but I've been looking over the same code too much & now I can't see anything properly
Here's what I'm using;
Code: Select all
Const strRegKey = "HKEY_CURRENT_USER\Software\CutePDF Writer\"
Dim wsh As Object
On Error GoTo ErrHandler
Set wsh = CreateObject("WScript.Shell")
' Store current printer in variable
Dim prt As Printer
Set prt = Application.Printer
' Tell Cute PDF not to prompt for the filename
wsh.regwrite strRegKey & "BypassSaveAs", "1"
' Now set the printer to Cute PDF, and open the report
Application.Printer = Application.Printers("CutePDF Writer")
' Specify filename
wsh.regwrite strRegKey & "OutputFile", "F:\ISO 18001\Risk Assessments\Obsolete Docs\Obsolete RAs\Output.pdf"
' Print the report
stDocName = "rptIndHnS2"
DoCmd.OpenReport stDocName, acNormal, , WhereCondition:="ID=" & Chr(34) & Me.ID & Chr(34)
MsgBox "Report printed to PDF", vbInformation
'Restore original printer
Set Application.Printer = prt
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Is it possible to... (PDF)
The DLLs are for Stephen Lebans' code, they don't have to do anything with CutePDF.
The code you posted is for CutePDF. As noted, I don't have this utility, so I can't help you with that.
The code you posted is for CutePDF. As noted, I don't have this utility, so I can't help you with that.
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Is it possible to... (PDF)
A bit of wishfull thinking on my behalf (from kwvh 's post)
Ho humm.
Ho humm.
-
- 3StarLounger
- Posts: 308
- Joined: 24 Feb 2010, 13:41
Re: Is it possible to... (PDF)
Sorry for the confusion.
You can take a look at the attached. I use variations of it to batch reports to specific directories, without the prompts.
I hope this helps.
Ken
You can take a look at the attached. I use variations of it to batch reports to specific directories, without the prompts.
I hope this helps.
Ken
You do not have the required permissions to view the files attached to this post.
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Is it possible to... (PDF)
Well that works (well gets one report printed before Access crashes), but the code is way more complex than anything I can edit (much as I'd like to, but I'd get lost SO quick :( )
If I post a stripped down version of my DB, could you do your magic on it please?
TIA
If I post a stripped down version of my DB, could you do your magic on it please?
TIA
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Is it possible to... (PDF)
Bit of a re-visit: we are now using Access2013 and as this has pdf support built in, the code used before (shown below) no longer works.
How would be the best manner to save a record / report to pdf (in a defined folder)?
Cheers
How would be the best manner to save a record / report to pdf (in a defined folder)?
Cheers
Code: Select all
Private Sub Prt2PDF_Click()
Const strRegKey = "HKEY_CURRENT_USER\Software\CutePDF Writer\"
Dim wsh As Object
On Error GoTo ErrHandler
Set wsh = CreateObject("WScript.Shell")
' Store current printer in variable
Dim prt As Printer
Set prt = Application.Printer
Dim stDocName As String
'Save the record
DoCmd.RunCommand acCmdSaveRecord
' Now set the printer to Cute PDF, and open the report
Application.Printer = Application.Printers("CutePDF Writer")
MsgBox "Place the PDF in; " & vbCr & "F:\ISO 18001\Archive\Risk Assessments\Archived RAs"
' Print the report
stDocName = "rptIndHnS2"
DoCmd.OpenReport stDocName, acNormal, , WhereCondition:="ID=" & Chr(34) & Me.ID & Chr(34) & "And Version=" & Me.Version
'Restore original printer
Set Application.Printer = prt
MsgBox "Report printed to PDF", vbInformation
ExitHandler:
On Error Resume Next
' Tell Cute PDF to prompt for the filename again
wsh.regwrite strRegKey & "BypassSaveAs", "0"
Set wsh = Nothing
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
Resume ExitHandler
End Sub
-
- Administrator
- Posts: 78446
- Joined: 16 Jan 2010, 00:14
- Status: Microsoft MVP
- Location: Wageningen, The Netherlands
Re: Is it possible to... (PDF)
Like this?
Code: Select all
Private Sub Prt2PDF_Click()
Dim stDocName As String
Dim strPath As String
On Error GoTo ErrHandler
'Save the record
If Me.Dirty Then Me.Dirty = False
strPath = "F:\ISO 18001\Archive\Risk Assessments\Archived RAs"
MsgBox "Place the PDF in; " & vbCr & strPath
' Print the report
stDocName = "rptIndHnS2"
DoCmd.OpenReport stDocName, acViewPreview, , WhereCondition:="ID=" & Chr(34) & Me.Id & Chr(34) & "AND Version=" & Me.Version
DoCmd.OutputTo acOutputReport, , acFormatPDF, strPath & "\" & stDocName & ".pdf"
DoCmd.Close acReport, stDocName, acSaveNo
MsgBox "Report printed to PDF", vbInformation
Exit Sub
ErrHandler:
MsgBox Err.Description, vbExclamation
End Sub
Best wishes,
Hans
Hans
-
- 5StarLounger
- Posts: 736
- Joined: 18 Mar 2010, 11:05
Re: Is it possible to... (PDF)
That's the job :)
thank you
thank you