Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2004

    Unanswered: Export reports to pdf - multiple files

    I have large SQL Server database (many tables) that has to go to multiple reports, pdf files, different filenames generated by field from the database table.

    Macros cannot do the job, of course. I started with VB.

    Made connection string.

    I made loop that can choose (for example) cities for pdf filenames (which I take from a table).

    For each city it has to make a single report and send it to a pdf file.

    Making report is not so complicated, but - how to send it to a pdf printer (one of printers from the list of printers, without a must to configure (for example) cutepdf as a default printer), and how to send the filename for it?

    Any good tutorial for this that includes VB code?

  2. #2
    Join Date
    Nov 2005
    I have had a similar issue once. The way I found to do this in Access is to change the default printer to the pdf printer (I think I did this in a bat file because I couldn't find a way to do it in VBA) and when you do the export of the file make the file name a variable.
    I can't seem to find the code right now. I will look for it again. If I find it I will post it.

  3. #3
    Join Date
    Jun 2004
    Arizona, USA

    Are you using standalone VB, or VBA (which is a subset of true VB, and is available from within an Office app like Access or Excel) ?

    If you're using VB, ref the code in this thread at a sister-site. Note that CutePDF doesn't allow you to programatically supply the pdf file name - you have to enter it manually each time you print.
    Last edited by loquin; 08-31-06 at 19:03.
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

  4. #4
    Join Date
    Apr 2004
    Derbyshire, UK
    Provided Answers: 2

    Sending File Name to CutePDF


    A year ago I found CutePDF via this site, which was very usefull as I no longer had use of Adoby Writer, which had been used to automate printing PDF Reports from Excel.

    This was achieved using SendKeys. Not recomended I know but needs must !

    However, using CutePDF was not strait forward (is it ever!).

    Having selected the PDF printer in code, and constucted the file (with path) name(s), this code was used with Adobe Writer

    Sub PrintToAdobePDF(FilePath As String)
        SendKeys "%FP~" & FilePath & "~", True
    End Sub
    After experimenting with CutePDF I found that a delay was required, therefore this code used with CutePDF

    Sub PrintToCutePDF(FilePath As String, RequiredDelay As Single)
        SendKeys "%FP~", True
        Pause RequiredDelay
        SendKeys FilePath & "~", True
        Pause RequiredDelay
    End Sub
    A delay of 2.5 seconds seemed to work.

    The Pause() function also seemed to need DoEvents in the loop.

    I have not used this a great deal as the requiement for the reports was lost at this time, and I suspect it is not very robust, but it was the only way I could do it??

    The previous Adobe writer worked very well creating dozens of reports over an uninterupted 20 minute period. But you do have to stop all other programs interfering while it runs (ie. tun off e-mail 'you got mail' popups as these then take the sent keys !) .

    I don't know if that helps, but I would be interested if it works for you.


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts