+ Reply to Thread
Results 1 to 17 of 17

Generate PDF files based on the content

  1. #1
    Registered User
    Join Date
    12-22-2016
    Location
    Sri Lanka
    MS-Off Ver
    2016
    Posts
    12

    Question Generate PDF files based on the content

    Hi everyone,
    I have no idea whatsoever about macro or vba and I think the problem I have faced maybe solved with macro in excel.
    OK, here it is,

    I have a growing list with a unique code consists of numbers and letters in column A and in column B a description about the item in column A code.

    ex.

    A____________________B
    BY8EMCT01___________Bracelet in 18K Yellow Gold with an Emarald and Citrines
    BY4CTXX01___________Bracelet in 14K Yellow Gold with a Citrine
    BY8AMXX01___________Bracelet in 18K Yellow Gold with Amethysts

    I need to generate a PDF file based on the items in column A and if possible the description should be written on that particular pdf generated (this is not a must though).

    I should be able to come back again when the list is grown and generate the pdf files again without over writing the previously generated pdf files.

    Thanks every in advance for taking your time to help.
    Last edited by chathuranga; 12-27-2016 at 11:33 PM. Reason: not showing up correctly

  2. #2
    Forum Expert
    Join Date
    11-28-2012
    Location
    Guatemala
    MS-Off Ver
    Excel 2010
    Posts
    2,394

    Re: Generate PDF files based on the content

    Hi, the needed outcome is not clear to me, is it the same as the input?

    Assuming it is, the PDF creation can be done by saving the excel file (use SAVE AS) and choose PDF as its extension..

  3. #3
    Registered User
    Join Date
    12-22-2016
    Location
    Sri Lanka
    MS-Off Ver
    2016
    Posts
    12

    Re: Generate PDF files based on the content

    Quote Originally Posted by rcm View Post
    Hi, the needed outcome is not clear to me, is it the same as the input?

    Assuming it is, the PDF creation can be done by saving the excel file (use SAVE AS) and choose PDF as its extension..
    Hi, Sorry for not being so clear.

    No, I am not trying to save the sheet as a pdf.
    The Column A items keep growing from time to time. In the example Ive given above have only three entries. I need a pdf file for each entry at the column A. So I need a method to generate three pdf files on these items. For example i need these three pdf files to be generated into a folder.
    BY8EMCT01.pdf
    BY4CTXX01.pdf
    BY8AMXX0.pdf

  4. #4
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Generate PDF files based on the content

    You can place the following macro into a routine module and call with a Command Button:

    Please Login or Register  to view this content.

  5. #5
    Registered User
    Join Date
    12-22-2016
    Location
    Sri Lanka
    MS-Off Ver
    2016
    Posts
    12

    Re: Generate PDF files based on the content

    Hi Logit,
    Thank you for taking your time. But this gives me all the data in sheet 1 to a pdf file (I'm not sure if I'm doing this correctly though). I need separate pdf file for each and every row with data.
    Last edited by AliGW; 12-29-2016 at 03:52 AM. Reason: Extraneous quotation removed.

  6. #6
    Forum Expert Logit's Avatar
    Join Date
    12-23-2012
    Location
    North Carolina
    MS-Off Ver
    Excel 2019 Professional Plus - 2007 Enterprise
    Posts
    7,014

    Re: Generate PDF files based on the content

    The following code will do what you are seeking :

    Please Login or Register  to view this content.
    The only thing I don't understand with this macro ... If your data begins in A1, for some reason this code will delete the contents of A1 when it finishes.
    There is nothing in the code that creates that action, so it's confusing to me. Let me know if it does the same thing for you - maybe it's just a quirk
    on my system.

    A simple solution is to make certain your data begins in A2.

    If anyone has an edit to the code that will prevent the deletion of data from A1 (as the code is presently written) ... please contribute.

    Hope this helps.
    Attached Files Attached Files
    Last edited by Logit; 12-28-2016 at 07:50 PM.

  7. #7
    Registered User
    Join Date
    12-22-2016
    Location
    Sri Lanka
    MS-Off Ver
    2016
    Posts
    12
    Hi Logit,
    I have tried your. Seems the command is running but I cant find where the pdf files are saved. :-)
    And yes the problem with A1 cell is there and its going to be a problem.

    Thanks a lot for taking your valuable time. i have attached a file found in the internet which does the job. However, this have a problem overwriting the existing files.

    Please have a look if you have time.

    Thanks again.
    Attached Files Attached Files
    Last edited by AliGW; 12-29-2016 at 03:51 AM. Reason: Extraneous quotation removed.

  8. #8
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Generate PDF files based on the content

    @ chathuranga

    Please stop quoting when you give a direct answer to the previous post. It just clutters this thread.

    generate the pdf files again without over writing the previously generated pdf files.
    How do you plan to keep 2 files with the same name in 1 directory.
    Avoid using Select, Selection and Activate in your code. Use With ... End With instead.
    You can show your appreciation for those that have helped you by clicking the * at the bottom left of any of their posts.

  9. #9
    Registered User
    Join Date
    12-22-2016
    Location
    Sri Lanka
    MS-Off Ver
    2016
    Posts
    12

    Re: Generate PDF files based on the content

    Hi bakerman2,
    Sorry about the quoting.
    I wont be needing to keep 2 files with same name in one directory. I just want the command to write new pdf files for the next additional row values.

    For example, if i have three values in the rows of column A like this
    BY8EMCT01
    BY4CTXX01
    BY8AMXX0
    and when i first run the command I should get these files
    BY8EMCT01.pdf
    BY4CTXX01.pdf
    BY8AMXX0.pdf

    Then When I have another value in the next row of column A, (eg BY4RMCT01) and when I run the command it should not overwrite the previously generated PDF files but generate only the new file BY4RMCT01.pdf

    The file I have attached to the above reply does the job, However it overwrites the previously generated files as well.

  10. #10
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Generate PDF files based on the content

    Then use the Dir-function in your loop to check wether the file already exists before exporting it as pdf.
    Something like

    Please Login or Register  to view this content.

  11. #11
    Registered User
    Join Date
    12-22-2016
    Location
    Sri Lanka
    MS-Off Ver
    2016
    Posts
    12

    Re: Generate PDF files based on the content

    But then I will have to modify the code each time I have a new row addition, right ?
    That will be a PIA. :-)

  12. #12
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Generate PDF files based on the content

    No, because you know the filename previous to exporting place that in the Dir-function and check.
    Like this.

    Please Login or Register  to view this content.

  13. #13
    Registered User
    Join Date
    12-22-2016
    Location
    Sri Lanka
    MS-Off Ver
    2016
    Posts
    12

    Re: Generate PDF files based on the content

    Ok this is the code I have, Could you please let me know to where I should include yours ?



    Please Login or Register  to view this content.
    Last edited by chathuranga; 12-29-2016 at 03:52 AM.

  14. #14
    Registered User
    Join Date
    12-22-2016
    Location
    Sri Lanka
    MS-Off Ver
    2016
    Posts
    12

    Re: Generate PDF files based on the content

    Sorry about that, Edited.

  15. #15
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Generate PDF files based on the content

    Gave you solution in my previous post.

    Please Login or Register  to view this content.

  16. #16
    Registered User
    Join Date
    12-22-2016
    Location
    Sri Lanka
    MS-Off Ver
    2016
    Posts
    12

    Re: Generate PDF files based on the content

    OK.
    It works. Thank you so much for all the help.
    I have spent days trying to figure this out.

    Thanks again.

  17. #17
    Forum Guru bakerman2's Avatar
    Join Date
    10-03-2012
    Location
    Antwerp, Belgium
    MS-Off Ver
    MO Prof Plus 2016
    Posts
    6,907

    Re: Generate PDF files based on the content

    You're welcome.

+ 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. How to generate an outlook message with the content from a particular worksheet.
    By DURGESH88 in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 12-29-2014, 09:09 AM
  2. Replies: 0
    Last Post: 09-09-2014, 05:21 PM
  3. Automatically copy cells content based on the content of another cell.
    By chrisbarlow1984 in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 02-01-2014, 11:13 AM
  4. [SOLVED] Generate a filename from cell's text content
    By epouepou in forum Excel Formulas & Functions
    Replies: 16
    Last Post: 10-24-2013, 01:48 PM
  5. [SOLVED] Export as pdf with different files based on cell content
    By wing_nut in forum Excel Programming / VBA / Macros
    Replies: 15
    Last Post: 10-06-2012, 07:59 PM
  6. Macro to open files based on cell content
    By livinglegend629 in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 05-16-2011, 03:41 PM
  7. vba script to generate files based on an data from an Excel sheet
    By bananas in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 10-30-2007, 03:00 PM

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