Working with PDF

User avatar
Cecilia
StarLounger
Posts: 89
Joined: 19 Feb 2010, 16:56
Location: San Francisco, Alameda, CA

Working with PDF

Post by Cecilia »

Well, my psycho boss is on the rampage and wants NO MORE snapshot files (prejudice much?). So I'm trying to write two types of code: one to convert snapshot files to pdf, and another to save reports as PDF.

For the first, convert existing snapshot files to PDF, if I go through Windows Explorer I get a right-click option, Covert to Adobe PDF, which makes me believe there is some sort of Shell command that might take care of this easily enough. Only problem is every time I think I'm getting close to finding a solution, I end up on a broken link. Anyone know would be the shell command to convert a snp file to pdf, assuming Adobe is properly installed?

For the second part, I found Hans' code as such:
' Save current printer
Set prtOldPrinter = Application.Printer
' Set Acrobat as default printer
Set Application.Printer = Application.Printers("Adobe PDF")
' Print report
DoCmd.OpenReport strReport

' Restore original printer
Set Application.Printer = prtOldPrinter

This will open the report, but how to save it? I've tried OutputTo with no success, I believe it is only available to Office 2007, and we're on 2003 for the time being.

TIA! :)

User avatar
HansV
Administrator
Posts: 78478
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Working with PDF

Post by HansV »

Access 2007 has export to PDF built in, without needing Adobe Acrobat. In older versions you can either use a PDF utility such as Adobe Acrobat or one of the many free/cheap alternatives, or use Stephen Lebans' Report to PDF, a code-only solution; it includes conversion from snapshot to PDF.

The code you mention will output the report to a PDF file (the Adobe PDF "printer" actually produces a file instead of paper output). Its name should correspond to the caption of the report.
Best wishes,
Hans

User avatar
Cecilia
StarLounger
Posts: 89
Joined: 19 Feb 2010, 16:56
Location: San Francisco, Alameda, CA

Re: Working with PDF

Post by Cecilia »

Thanks, Hans. I am trying to stay away from Steve Lebans' prog because of the two files that end in .dll, the last thing I need is alarm bells going off (even if they're not live or put in the registry). So I was hoping that there might be a one line shell command that would do the convert to pdf that I can see in Explorer.

When I ran the code, though, all I got was the view of the report on the screen, it didn't save the report anywhere, at least not anywhere that I can find it? and with no location to save the report to, it's kind of limited?

User avatar
HansV
Administrator
Posts: 78478
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Working with PDF

Post by HansV »

As far as I know, there is no "one line shell command that would do the convert to pdf" - the context menu entry that you see is put there by Adobe Acrobat.

The line

DoCmd.OpenReport strReport

should not open the report in preview mode, but print it directly (in this case to a PDF file), but if it does, you could change it to

DoCmd.OpenReport strReport, acNormal

You can always use code to move the file from the default location to the folder where you want it:

Name "Oldpath\Test.pdf" As "Newpath\Test.pdf"

where Oldpath and Newpath are strings specifying paths.
Best wishes,
Hans

kwvh
3StarLounger
Posts: 308
Joined: 24 Feb 2010, 13:41

Re: Working with PDF

Post by kwvh »

Cecilia wrote:Thanks, Hans. I am trying to stay away from Steve Lebans' prog because of the two files that end in .dll, the last thing I need is alarm bells going off (even if they're not live or put in the registry). So I was hoping that there might be a one line shell command that would do the convert to pdf that I can see in Explorer.

When I ran the code, though, all I got was the view of the report on the screen, it didn't save the report anywhere, at least not anywhere that I can find it? and with no location to save the report to, it's kind of limited?

I have used Lebans' prog for about 4 years in several environments without any problems. What is nice from my perspective is that it flexible and simple. For your convenience and review is a stripped down version of a database showing how to use it, including where it will create the pdf files.

Ken
You do not have the required permissions to view the files attached to this post.

User avatar
Cecilia
StarLounger
Posts: 89
Joined: 19 Feb 2010, 16:56
Location: San Francisco, Alameda, CA

Re: Working with PDF

Post by Cecilia »

HansV wrote: The line

DoCmd.OpenReport strReport

should not open the report in preview mode, but print it directly (in this case to a PDF file), but if it does, you could change it to

DoCmd.OpenReport strReport, acNormal

You can always use code to move the file from the default location to the folder where you want it:

Name "Oldpath\Test.pdf" As "Newpath\Test.pdf"

where Oldpath and Newpath are strings specifying paths.
Hm, today I tried the code again and it worked! Only problem is lack of control of folder, but yeah, renaming them would be simple enough. I'm just not certain it would default to My Documents for everyone.

On a side note, since this is a volunteer board, I was trying to figure out how to "give back." The level of brainage on this board is waaaay above mine, I doubt that (even if I were fast enough) I could adequately answer questions...is there some other way to help out?

User avatar
StuartR
Administrator
Posts: 12604
Joined: 16 Jan 2010, 15:49
Location: London, Europe

Re: Working with PDF

Post by StuartR »

Cecilia wrote:...is there some other way to help out?
The best way to contribute is to provide updates to your posts, saying what happened, and thanking anyone who contributed to the solution.
StuartR


User avatar
Cecilia
StarLounger
Posts: 89
Joined: 19 Feb 2010, 16:56
Location: San Francisco, Alameda, CA

Re: Working with PDF

Post by Cecilia »

kwvh wrote:
I have used Lebans' prog for about 4 years in several environments without any problems. What is nice from my perspective is that it flexible and simple. For your convenience and review is a stripped down version of a database showing how to use it, including where it will create the pdf files.

Ken
Thanks, Ken! I will take a look at your version. *I* personally am not against using Lebans' prog, you're right, it's the perfect solution. But I work for the gov't, and here people are, um, paranoid....if there is something that says dll on the end, it will no doubt trigger sirens that you will hear as far as south america. But maybe I should try it first, and look for a different solution if it does show up on their raidar?
Last edited by Cecilia on 25 Feb 2010, 18:03, edited 2 times in total.

User avatar
Cecilia
StarLounger
Posts: 89
Joined: 19 Feb 2010, 16:56
Location: San Francisco, Alameda, CA

Re: Working with PDF

Post by Cecilia »

StuartR wrote:
Cecilia wrote:...is there some other way to help out?
The best way to contribute is to provide updates to your posts, saying what happened, and thanking anyone who contributed to the solution.
Always! Always! Always! (Hans is my hero!) Maybe this board needs a Thank You button at the bottom of the posts? :)

User avatar
Cecilia
StarLounger
Posts: 89
Joined: 19 Feb 2010, 16:56
Location: San Francisco, Alameda, CA

Re: Working with PDF

Post by Cecilia »

Update: Tried to use the Lebans code...database crashed.

Think I'm sticking with Snapshots for now, if Mr. Cranky wants PDF, he'll have to wait for 2007, which we should have sometime around 2020. :bif:

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Working with PDF

Post by Pat »

psycho boss and Mr. Cranky.

Thanks Cecilia, an amusing post

User avatar
Cecilia
StarLounger
Posts: 89
Joined: 19 Feb 2010, 16:56
Location: San Francisco, Alameda, CA

Re: Working with PDF

Post by Cecilia »

Pat wrote:psycho boss and Mr. Cranky.

Thanks Cecilia, an amusing post
At least someone can get some amusement from my otherwise horrible work situation. Glad to be of service ;)

Pat
5StarLounger
Posts: 1148
Joined: 08 Feb 2010, 21:27

Re: Working with PDF

Post by Pat »

It's the wording i was amused at, not your horrible work situation.

User avatar
Cecilia
StarLounger
Posts: 89
Joined: 19 Feb 2010, 16:56
Location: San Francisco, Alameda, CA

Re: Working with PDF

Post by Cecilia »

Pat wrote:It's the wording i was amused at, not your horrible work situation.
Yeah, but the horrible work situation amuses me too, at times ;)

No worries, I got you the first time :)