Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Merge reports to single pdf 2

Status
Not open for further replies.

primagic

IS-IT--Management
Jul 24, 2008
476
GB
I am trying to merge multiple reports to a single pdf. I have looked at stephen labans database but it doesnt really help me out.

I have 15 checkboxes on a form and a command button that will take each of the ticked checkboxes and output them to pdf.

I want to then be able to merge all those reports to one pdf. Or can I output all the selected reports to one pdf?

Thanks
 
Hi again,

I have your code working perfect. Was just wondering is there anyway of creating a hyperlink from a table of contents page to the first page of each report?

My report0 is always a table of contents. This just lists the Report names. I was wondering if I could turn that into a hyperlink and link to the first page of each report in the merged document?


Is this possible?
 
How are ya sxschech . . .

Nice Job! ... worth another star for recognition ...

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thank you TheAceMan1. That was nice of you. Your advice has been helpful over the years, and am glad was able to provide something that is useful to others.
 
primagic, I'm sure it could be done, would have to look into it. It may need to be done on the acrobat side once the document is completed.
 
yes i am sure it could be done as well. but beyond my knowledge unfortunately :)

If you could come up with a solution, i would appreciate it alot.

Many thanks.

 
Following up on our topic...

Recently, after a Windows and Office update, I experienced the issue of the security popup box for each of the pdf's and found out that when I save the pdfs to the hard disk (C drive) I get the message, while if I save to a network drive, everything is fine. I spoke with our ITS dept and they tried several things in the registry settings, but haven't yet been able to fix the problem and recommended that since saving to the network doesn't cause the popups, that I change my code to save to the network rather than the C drive.

I haven't yet found a solution for the hyperlink table of contents, but did find a code solution to closing the pdf files without using sendkeys.

Go to the vba window and insert a new module. Paste the following code I found at '
The modification that I made was to accept the filename of the window to be closed via code rather than as an input box.

Code:
'[URL unfurl="true"]http://www.andreavb.com/forum/viewtopic_5604.html[/URL]
'Post:Asim-GDI GURU 
Option Compare Database


Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function PostMessage Lib "user32" Alias "PostMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Function ShowWindow Lib "user32" (ByVal hwnd As Long, ByVal nCmdShow As Long) As Long
Const SW_SHOWNORMAL = 1
Const WM_CLOSE = &H10

Public Sub WinClose(WindowToClose As String)
    'KPD-Team 1998
    'URL: [URL unfurl="true"]http://www.allapi.net/[/URL]
    'E-Mail: KPDTeam@Allapi.net
    Dim WinWnd As Long ', Ret As String,
    Dim RetVal As Long, lpClassName As String
    'Ask for a Window title
    'Ret = InputBox("Enter the exact window title:" + Chr$(13) + Chr$(10) + "Note: must be an exact match")
    ret = WindowToClose
    'Search the window
    WinWnd = FindWindow(vbNullString, ret)
    If WinWnd = 0 Then MsgBox "Couldn't find the window ...": Exit Sub
    'Show the window
    ShowWindow WinWnd, SW_SHOWNORMAL
    'Post a message to the window to close itself
    PostMessage WinWnd, WM_CLOSE, 0&, 0&
End Sub

Next in the MergePDF code replace this section
Code:
'Close the open pdf files except for the Merged report
 FollowHyperlink Replace(pdfsrc, "0", X - 1), , True, False
 SendKeys "%{F4}", False

with

Code:
'Close the open pdf files except for the Merged report
DoEvents
Call WinClose(Replace(Mid(pdfsrc, InStrRev(pdfsrc, "\") + 1), "0", X - 1) & " - Adobe Acrobat Pro")
DoEvents

The WinClose is used to close other open Adobe Acrobat application windows, which is useful if you want to close a specific window without closing the entire application that may have other open windows. You can find out the syntax by looking at the Title Bar (above the File menu) of the open Acrobat PDF file window you want to close.

Example:

WinClose("rptMyReportName.pdf - Adobe Acrobat Pro")
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top