1. Welcome to Chandoo.org Forums. Short message for you

    Hi Guest,

    Thanks for joining Chandoo.org forums. We are here to make you awesome in Excel. Before you post your first question, please read this short introduction guide. When posting or responding to questions please remember our values at Chandoo.org are: Humility, Passion, Fun, Awesomeness, Simplicity, Sharing Remember that we have people here for whom English is not there first language and we need to allow for this in our dealings.

    Yours,
    Chandoo
  2. Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  3. When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Help me to create multiple PDF files with cell value as file name

Discussion in 'VBA Macros' started by uranus99, Feb 13, 2019.

  1. uranus99

    uranus99 New Member

    Messages:
    4
    Hello my name is Roger.
    I wanna create multiple PDF files with cell value as file name.

    i found this code in internet
    Code (vb):
    Sub Rectangle1_Click()
    On Error Resume Next
       MkDir ThisWorkbook.Path & "\SAVE AS PDF\"
       On Error GoTo 0

    Filename = Sheets("Card").Range("B1") & "-" & Sheets("Card").Range("B2")
    If Sheets("Card").Range("B1") = "" Then
    MsgBox "Invalid", vbCritical, "Failed to Save"
    Exit Sub
    Else
       With ThisWorkbook.ActiveSheet
           fName = Filename
       End With
       '
      'export to pdf
      ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
                   ThisWorkbook.Path & "\SAVE AS PDF\" & fName, Quality:=xlQualityStandard, _
                   IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False

    MsgBox "File " & Filename & ".pdf successfull save as PDF", vbInformation, "Convert To PDF"
    End If
    End Sub
     
    [​IMG] upload_2019-2-13_11-42-44.gif
    [​IMG] upload_2019-2-13_11-42-44.gif

    with that code, I can only save one data that appears on the sheet card.
    Can anyone help me to Save all data as PDF in Score sheet in the form of Card Sheet just one click?? so i can have multiple PDF files
  2. vletm

    vletm Excel Ninja

    Messages:
    4,793
    uranus99
    What data (which range) would You try to 'save as PDF' from 'Score'-sheet?
    You would modify code:
    1) take away that With ... End With
    2) change ActiveSheet to Sheets("Score")
    3) .. and someway tell ... which range

    >> Upload a File to get a quicker response <<
  3. uranus99

    uranus99 New Member

    Messages:
    4
    From A1 to B3.
    I want to have All pdf file (total 15 PDFs) with sheet "Card" format from ID 10001 to 10015 with just one click.
    i hope someone know the Code so i can do that

    Attached Files:

    Last edited: Feb 13, 2019
  4. vletm

    vletm Excel Ninja

    Messages:
    4,793

    Attached Files:

    uranus99 likes this.
  5. uranus99

    uranus99 New Member

    Messages:
    4
    WOW THANKSS THAT WHAT I LOOKING FOR :DD
    That will save my time, thank you very much
    but can i ask something
    what if i have 5000 data & then i only want to create PDF from data ID 400 to 1000 which code that i need to replace or add?
  6. vletm

    vletm Excel Ninja

    Messages:
    4,793
    uranus99
    If You ask .. all then You should mean all...
    If would have asked other way, it won't need to do many things...
    Just for sure, I did third version too - - You can name which IDs...

    Attached Files:

    uranus99 likes this.
  7. uranus99

    uranus99 New Member

    Messages:
    4
    thank you very much you know what i need.
    i really appreciate your help.

    but to be honest that file only for my practice.
    my true project has 5000 data and i cant upload coz of privacy.
    im still noob on coding and need more practice.

    i still need your hand.
    my project print area is A1 to AP103
    and file name on O12"-"O22
    which code that i need to change from ur last file to make what i looking for?
  8. vletm

    vletm Excel Ninja

    Messages:
    4,793
    uranus99
    Sample File should have same layout as use, especially if 'still noob'.

    All matters ... all matters!
    With print area, it's possible to help
    ... select Your needed range from that sheet and
    'set print area' via menu as with any other cases.

    Other 'settings' depends of
    a) which version of those three or all?
    b) what else there would be ...?
    c) and so on...

Share This Page