Consulting

Page 2 of 2 FirstFirst 1 2
Results 21 to 24 of 24

Thread: Solved: Printing multiple worksheets to a single pdf file

  1. #21
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Try this version. Will have the name of the workbook + pdf. As a bonus, program will open search explorer with the following searchcriteria : all pdf's in the directory of the active workbook.

    Hope you like this one.

  2. #22
    VBAX Master
    Joined
    Jul 2006
    Location
    Belgium
    Posts
    1,286
    Location
    Alternate routine (and much quicker altough it was not originally created for this) originally from Ivan F. Moala and modified (5 %) by me.[vba]Option Explicit
    Private Declare Function GetOpenFileName Lib "comdlg32.dll" _
    Alias "GetOpenFileNameA" ( _
    pOpenfilename As OPENFILENAME) As Long
    Private Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
    End Type
    Sub Display_PDF()
    Dim OpenFile As OPENFILENAME
    Dim lReturn As Long
    Dim strFilter As String
    OpenFile.lStructSize = Len(OpenFile)
    '// Define your wildcard string here
    '// Note we pad the strings with Chr(0)
    '// This indicates an end of a string
    strFilter = "*.pdf" & Chr(0) & "*.pdf" & Chr(0)
    With OpenFile
    .lpstrFilter = strFilter
    .nFilterIndex = 1
    .lpstrFile = String(257, 0)
    .nMaxFile = Len(.lpstrFile) - 1
    .lpstrFileTitle = .lpstrFile
    .nMaxFileTitle = .nMaxFile
    .lpstrInitialDir = ActiveWorkbook.Path
    .lpstrTitle = "Display PDF's in Workbook Directory ..."
    .flags = 0
    End With
    lReturn = GetOpenFileName(OpenFile)
    If lReturn = 0 Then
    '// User cancelled Do your thing
    Exit Sub
    Else
    '// Do your thing
    MsgBox "You can't open pdf files with this function." & vbCrLf & _
    "Rightclick the file you want and use 'open with ...'" & vbCrLf & _
    "to view the pdf-file you selected.", vbInformation
    Call Display_PDF
    End If
    End Sub[/vba]
    Last edited by Charlize; 06-22-2007 at 02:35 AM.

  3. #23
    I couldn't do much with the second one ( i get the error that only comments can come after "end")

    the first one looks great but if possible i'd like it to do a much simpler action, just open the active.path location (if that is possible) just sothe whole contents of that folder is shown.
    Part of why i would like that better is to ensure people actively see what folder is saved to and not lose it. BTW sorry for not seeing the second page to this thread before now.

  4. #24
    Solved:

    I used Richard Schollar's bit of code and inserted it in place of the search window code, after I figured out how your code works.

    Charlize, thanks!!!

Posting Permissions

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