+ Reply to Thread
Results 1 to 12 of 12

VBA to copy details from excel and save as PDF

  1. #1
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    VBA to copy details from excel and save as PDF

    Dear Team,
    Need your help please.

    I have a file with associates and their respective project details. Column E has the project ID details.

    The manual activity that I does is, I filter a project ID and then copy all the details related to that project to a new excel file and then save it as PDF file in a desktop folder. Repeat the same for next project ID. So if there are 10 Project IDs in the file, I create 10 PDF Files.

    Need help with a macro code to automate this. Sample file attached.



    There is another similar activity that I does for which I already have the code. However in this activity after filtering the project ID in a column, the details are saved as an Excel file and not PDF.

    Below is the code for that for reference.

    Please Login or Register  to view this content.
    Attached Files Attached Files

  2. #2
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: VBA to copy details from excel and save as PDF

    Please Login or Register  to view this content.
    Last edited by sintek; 08-19-2020 at 07:26 AM.
    Good Luck
    I don't presume to know what I am doing, however, just like you, I too started somewhere...
    One-day, One-problem at a time!!!
    If you feel I have helped, please click on the star to left of post [Add Reputation]
    Also....add a comment if you like!!!!
    And remember...Mark Thread as Solved.
    Excel Forum Rocks!!!

  3. #3
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: VBA to copy details from excel and save as PDF

    Quote Originally Posted by sintek View Post
    Please Login or Register  to view this content.
    Thank you so much.

    The data is being saved as PDF but only the header is available in the PDF. Screenshot attached. After filtering one project ID, expectation is to paste all the available details and save as PDF.

    Can you please help.

    Attachment 691703

  4. #4
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: VBA to copy details from excel and save as PDF

    but only the header is available in the PDF
    Not with the sample file...see result...


    Try this ... small change...
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by sintek; 08-19-2020 at 07:56 AM.

  5. #5
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: VBA to copy details from excel and save as PDF

    Quote Originally Posted by sintek View Post
    Not with the sample file...see result...


    Try this ... small change...
    Please Login or Register  to view this content.
    Thank you so much... This is working perfectly fine..

    Not with the sample file, but when i tried in different file, the project ID is not displayed completely.. Like we need to do an "Auto fit". Screenshot attached. Requesting your help again..

    Attachment 691707

  6. #6
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: VBA to copy details from excel and save as PDF

    Not with the sample file, but when i tried in different file, the project ID is not displayed completely
    So where is sample file showing actual setup...Why not use this from the GetGo with dummy data...

    Your attachment is not valid...

    Also...No need to quote entire posts if there is only Me and You in thread...See above quote...small...

    Anyway...Insert red part...
    Please Login or Register  to view this content.

  7. #7
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: VBA to copy details from excel and save as PDF

    No need to quote entire posts if there is only Me and You in thread
    Sure.. Thanks for guiding me on this..

    When the name of associate or Project is lengthy, the data in column F goes to the second sheet. The columns are going to be only till F but the length of the names can change. Can you please help.. so all data till column F is pasted as in one table..

    Attached the sample file and the pdf file.
    Attached Files Attached Files

  8. #8
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: VBA to copy details from excel and save as PDF

    Why don't you manually setup your sheet print area prior...
    OR
    Please Login or Register  to view this content.
    Last edited by sintek; 08-19-2020 at 08:54 AM.

  9. #9
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: VBA to copy details from excel and save as PDF

    Thank you so much.. This is working perfectly fine.

    One more help that i need here is - I am able to run the macro only once .. when i run for the 2nd time, it throws error since there is already pdf file with same name.

    Can the pdf files be saved as "ABC" "Project ID" and "date and time". "ABC" is a text that i should be able to change in the code to diff name. "Project ID" is the value from column E.. Date and time is the current date and time, with this i can run the macro any number of times.

    Can you please help..
    Last edited by arun.sj; 08-20-2020 at 05:06 AM.

  10. #10
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: VBA to copy details from excel and save as PDF

    This will create same name with different date time stamp

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    06-05-2014
    MS-Off Ver
    Microsoft Office Professional Plus 2016
    Posts
    155

    Re: VBA to copy details from excel and save as PDF

    Parent.Range("A1:F" & lr).ExportAsFixedFormat xlTypePDF, Path & Data(i, 5) & "-" & Format(Now(), "dd-mm-yyyy hhmmAMPM"), xlQualityStandard, IncludeDocProperties
    Thank you so much..

  12. #12
    Forum Expert sintek's Avatar
    Join Date
    12-04-2015
    Location
    Cape Town
    MS-Off Ver
    2013 | 2016 | 2019
    Posts
    13,122

    Re: VBA to copy details from excel and save as PDF

    If that takes care of your original question, please select Thread Tools from the menu link above and mark this thread as SOLVED...
    Thanks for rep +

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 2
    Last Post: 02-22-2018, 03:55 AM
  2. [SOLVED] Email Details to Excel & Save as .MSG on one macro - combination of 2 macros
    By nathandavies9 in forum Outlook Formatting & Functions
    Replies: 0
    Last Post: 03-21-2017, 12:17 PM
  3. [SOLVED] Excel formula needed to find string and then copy details from another cell
    By jopat in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 12-09-2014, 10:10 PM
  4. [SOLVED] how can i search and copy details of a particular User details in Sheet1
    By baig123 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-10-2014, 02:58 AM
  5. Save Email Details in excel file
    By s_samira_21 in forum Outlook Programming / VBA / Macros
    Replies: 0
    Last Post: 08-06-2014, 04:12 AM
  6. Replies: 0
    Last Post: 08-21-2012, 01:19 AM
  7. [SOLVED] Can I get excel to auto save details from a cell into the doc nam.
    By excelnewbie in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 09-16-2005, 03:05 AM

Tags for this Thread

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1