Access XP
WinXP
Adobe Acrobat 5.0
I'm playing with Keri Hardwick's "Save a report's output as a PDF file" and
most of it still works. The problem is the ChangePdfFileNa me is not changing
the file name and it is storing the file in "My Documents" with the standard
report name. What appears to be going on is that the PDFWriter is not
reading the PDFFilename from the Win.ini. It's reading the PDFFilename value
from the registry if it exsists. If it doesn't exsist it just uses default
values which I don't want.
Here is the code so far:
[color=blue][color=green][color=darkred]
>>>Start Code[/color][/color][/color]
Option Compare Database
Option Explicit
' These functions used with procedures from
' Microsoft Access 95 How-To
'(c) 1998 Ken Getz and Paul Litwin
' All rights reserved.
Private drexisting As aht_tagDeviceRe c
Const AcrobatName = "Acrobat PDFWriter"
Const AcrobatDriver = "PDFWRITR"
Const AcrobatPort = "LPT1:"
Sub ResetDefaultPri nter()
Call ahtSetDefaultPr inter(drexistin g)
End Sub
Function ChangeToAcrobat ()
If ahtGetDefaultPr inter(drexistin g) Then
Dim dr As aht_tagDeviceRe c
With dr
.drDeviceName = AcrobatName
.drDriverName = AcrobatDriver
.drPort = AcrobatPort
End With
Call ahtSetDefaultPr inter(dr)
End If
End Function
Sub ChangePdfFileNa me(NewFileName As String)
Call aht_apiWritePro fileString("Acr obat PDFWriter", "PDFFileNam e",
NewFileName)
End Sub
[color=blue][color=green][color=darkred]
>>>And Here is the trigger for the whole thing:[/color][/color][/color]
Private Sub Command6_Click( )
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "RptDailyPD F"
DoCmd.Close acReport, "RptDailyPD F"
stLinkCriteria = "[ACCT#] = " & "'" & Me![ACCT#] & "'" & "and " &
"[WSDate1] = " & "'" & Me![WSDate1] & "'"
ChangeToAcrobat
ChangePdfFileNa me ([ACCT#] & Format([WSDate1], "yyyymmdd") & ".PDF")
DoCmd.OpenRepor t stDocName, acViewNormal, , stLinkCriteria
ResetDefaultPri nter
End Sub
[color=blue][color=green][color=darkred]
>>>End code[/color][/color][/color]
Everything works except the file rename like I described. Any help is
appriciated. Also, I haven't posted any questions in a very long time so if
I've stepped on toes or violated a FAQ rule somewhere, just let me know and
I'll reform my ways.
Thanks,
Michael Harris
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.532 / Virus Database: 326 - Release Date: 10/27/2003
WinXP
Adobe Acrobat 5.0
I'm playing with Keri Hardwick's "Save a report's output as a PDF file" and
most of it still works. The problem is the ChangePdfFileNa me is not changing
the file name and it is storing the file in "My Documents" with the standard
report name. What appears to be going on is that the PDFWriter is not
reading the PDFFilename from the Win.ini. It's reading the PDFFilename value
from the registry if it exsists. If it doesn't exsist it just uses default
values which I don't want.
Here is the code so far:
[color=blue][color=green][color=darkred]
>>>Start Code[/color][/color][/color]
Option Compare Database
Option Explicit
' These functions used with procedures from
' Microsoft Access 95 How-To
'(c) 1998 Ken Getz and Paul Litwin
' All rights reserved.
Private drexisting As aht_tagDeviceRe c
Const AcrobatName = "Acrobat PDFWriter"
Const AcrobatDriver = "PDFWRITR"
Const AcrobatPort = "LPT1:"
Sub ResetDefaultPri nter()
Call ahtSetDefaultPr inter(drexistin g)
End Sub
Function ChangeToAcrobat ()
If ahtGetDefaultPr inter(drexistin g) Then
Dim dr As aht_tagDeviceRe c
With dr
.drDeviceName = AcrobatName
.drDriverName = AcrobatDriver
.drPort = AcrobatPort
End With
Call ahtSetDefaultPr inter(dr)
End If
End Function
Sub ChangePdfFileNa me(NewFileName As String)
Call aht_apiWritePro fileString("Acr obat PDFWriter", "PDFFileNam e",
NewFileName)
End Sub
[color=blue][color=green][color=darkred]
>>>And Here is the trigger for the whole thing:[/color][/color][/color]
Private Sub Command6_Click( )
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "RptDailyPD F"
DoCmd.Close acReport, "RptDailyPD F"
stLinkCriteria = "[ACCT#] = " & "'" & Me![ACCT#] & "'" & "and " &
"[WSDate1] = " & "'" & Me![WSDate1] & "'"
ChangeToAcrobat
ChangePdfFileNa me ([ACCT#] & Format([WSDate1], "yyyymmdd") & ".PDF")
DoCmd.OpenRepor t stDocName, acViewNormal, , stLinkCriteria
ResetDefaultPri nter
End Sub
[color=blue][color=green][color=darkred]
>>>End code[/color][/color][/color]
Everything works except the file rename like I described. Any help is
appriciated. Also, I haven't posted any questions in a very long time so if
I've stepped on toes or violated a FAQ rule somewhere, just let me know and
I'll reform my ways.
Thanks,
Michael Harris
---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.532 / Virus Database: 326 - Release Date: 10/27/2003
Comment