Print a report and save it automatically as pdf

  • Thread starter Deema via AccessMonster.com
  • Start date
D

Deema via AccessMonster.com

Hi,
I need to print and save a report in access97 automatically as
pdf... I saw this code that is done by Ken Getz and Paul Litwin,
when i add the last part that calls the module in "ON Click" i get
an error message " Ambiguous name detected: ChangeToAcrobat"..
PS: I imported the modules from defaultprt.zip....
Could anyone tell me how to fix this problem.
thanks for any help you can give.

=====================================================
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.

' Other modules from this source are:
' basDefaultPrinter
' basGetPrinters
' basIniFile
' basPrintTypes
' basToken

' You'll also need defaultprt.zip

Private drexisting As aht_tagDeviceRec
Const AcrobatName = "Acrobat PDFWriter"
Const AcrobatDriver = "PDFWRITR"
Const AcrobatPort = "LPT1:"
Sub ResetDefaultPrinter()
Call ahtSetDefaultPrinter(drexisting)
End Function
Function ChangeToAcrobat()
If ahtGetDefaultPrinter(drexisting) Then
Dim dr As aht_tagDeviceRec
With dr
.drDeviceName = AcrobatName
.drDriverName = AcrobatDriver
.drPort = AcrobatPort
End With
Call ahtSetDefaultPrinter(dr)
End If
End Function

Sub ChangePdfFileName(NewFileName As String)
Call aht_apiWriteProfileString("Acrobat PDFWriter", _
"PDFFileName", NewFileName)
End Sub


Create the print file. To do this, add the following lines to the
appropriate place in your code (perhaps in reaction to a button
click):
ChangeToAcrobat
ChangePdfFileName "Name of pdf file including .pdf"
DoCmd.OpenReport "YourReportName", acViewNormal
ResetDefaultPrinter
 
D

Douglas J Steele

The error message implies that you have two different routines named
ChangeToAcrobat in your application. Do a search, and eliminate one of them.
 
D

Deema via AccessMonster.com

Hi Douglas,
Thanks a lot, i get no error message now....but this code does not save the
report automatically!!! What shall i do to get this report saved
automatically under different name each time...since now when i do print i
get the report name.pdf and i have to save it manually..
Thanks again for any help you can give.
The error message implies that you have two different routines named
ChangeToAcrobat in your application. Do a search, and eliminate one of them.
Hi,
I need to print and save a report in access97 automatically as
[quoted text clipped - 53 lines]
DoCmd.OpenReport "YourReportName", acViewNormal
ResetDefaultPrinter
 
D

Douglas J. Steele

Sorry, I'm not familiar with that particular piece of code from the ADH.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Deema via AccessMonster.com said:
Hi Douglas,
Thanks a lot, i get no error message now....but this code does not save
the
report automatically!!! What shall i do to get this report saved
automatically under different name each time...since now when i do print i
get the report name.pdf and i have to save it manually..
Thanks again for any help you can give.
The error message implies that you have two different routines named
ChangeToAcrobat in your application. Do a search, and eliminate one of
them.
Hi,
I need to print and save a report in access97 automatically as
[quoted text clipped - 53 lines]
DoCmd.OpenReport "YourReportName", acViewNormal
ResetDefaultPrinter
 
D

Deema via AccessMonster.com

Hi Douglas,
Thanks a lot for taking the time to reply.....it's been a while that i'm
searching for a pieace of code that print a report and save it automatically
as pdf under different name each time and i couldn't really find a complete
one, since i'm not really familiar with VBA .....So if you know another code
that does it,let me know.
Thanks .
Sorry, I'm not familiar with that particular piece of code from the ADH.
Hi Douglas,
Thanks a lot, i get no error message now....but this code does not save
[quoted text clipped - 13 lines]
 
D

Douglas J Steele

If you can upgrade to at least Access 2000, Stephen Lebans has a complete
solution for free at http://www.lebans.com/reporttopdf.htm

Otherwise, see whether anything Tony Toews has at
http://www.granite.ab.ca/access/pdffiles.htm helps. I think PDF995 is
capable of doing what you want, or check out ACG Soft at
http://ourworld.compuserve.com/homepages/attac-cg/acgsoft.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Deema via AccessMonster.com said:
Hi Douglas,
Thanks a lot for taking the time to reply.....it's been a while that i'm
searching for a pieace of code that print a report and save it automatically
as pdf under different name each time and i couldn't really find a complete
one, since i'm not really familiar with VBA .....So if you know another code
that does it,let me know.
Thanks .
Sorry, I'm not familiar with that particular piece of code from the ADH.
Hi Douglas,
Thanks a lot, i get no error message now....but this code does not
save
[quoted text clipped - 13 lines]
DoCmd.OpenReport "YourReportName", acViewNormal
ResetDefaultPrinter
 
S

Stephen Lebans

My solution works in A97 as well Douglas. I just got tired of maintaining 2
code bases so I only published the A2K version. It can be downconverted to
A97 with no issues.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Douglas J Steele said:
If you can upgrade to at least Access 2000, Stephen Lebans has a complete
solution for free at http://www.lebans.com/reporttopdf.htm

Otherwise, see whether anything Tony Toews has at
http://www.granite.ab.ca/access/pdffiles.htm helps. I think PDF995 is
capable of doing what you want, or check out ACG Soft at
http://ourworld.compuserve.com/homepages/attac-cg/acgsoft.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Deema via AccessMonster.com said:
Hi Douglas,
Thanks a lot for taking the time to reply.....it's been a while that i'm
searching for a pieace of code that print a report and save it automatically
as pdf under different name each time and i couldn't really find a complete
one, since i'm not really familiar with VBA .....So if you know another code
that does it,let me know.
Thanks .
Sorry, I'm not familiar with that particular piece of code from the ADH.

Hi Douglas,
Thanks a lot, i get no error message now....but this code does not save
[quoted text clipped - 13 lines]
DoCmd.OpenReport "YourReportName", acViewNormal
ResetDefaultPrinter
 
D

Douglas J Steele

I thought so.

However, since the OP is asking about Access 97, I assumed they didn't have
a newer version.

Thanks for the update.

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Stephen Lebans said:
My solution works in A97 as well Douglas. I just got tired of maintaining 2
code bases so I only published the A2K version. It can be downconverted to
A97 with no issues.

--

HTH
Stephen Lebans
http://www.lebans.com
Access Code, Tips and Tricks
Please respond only to the newsgroups so everyone can benefit.


Douglas J Steele said:
If you can upgrade to at least Access 2000, Stephen Lebans has a complete
solution for free at http://www.lebans.com/reporttopdf.htm

Otherwise, see whether anything Tony Toews has at
http://www.granite.ab.ca/access/pdffiles.htm helps. I think PDF995 is
capable of doing what you want, or check out ACG Soft at
http://ourworld.compuserve.com/homepages/attac-cg/acgsoft.htm

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


Deema via AccessMonster.com said:
Hi Douglas,
Thanks a lot for taking the time to reply.....it's been a while
that
i'm
searching for a pieace of code that print a report and save it automatically
as pdf under different name each time and i couldn't really find a complete
one, since i'm not really familiar with VBA .....So if you know another code
that does it,let me know.
Thanks .

Douglas J. Steele wrote:
Sorry, I'm not familiar with that particular piece of code from the ADH.

Hi Douglas,
Thanks a lot, i get no error message now....but this code does not save
[quoted text clipped - 13 lines]
DoCmd.OpenReport "YourReportName", acViewNormal
ResetDefaultPrinter
 
D

Deema via AccessMonster.com

Hi guys,
Thanks a lot for the website that you provided. i'll take a look and
hope that will work with me...

I thought so.

However, since the OP is asking about Access 97, I assumed they didn't have
a newer version.

Thanks for the update.
My solution works in A97 as well Douglas. I just got tired of maintaining 2
code bases so I only published the A2K version. It can be downconverted to
[quoted text clipped - 28 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top