The step by step tutorial shows how to design an Excel report and add Excel row data to it automatically by using Visual basic code and create a PDF file for each Excel row.
A sample sheet can be downloaded: …(read more)
Convert Word 2 PDF: Word to PDF Converter
Convert PowerPoint 2 PDF: PPT to PDF Converter
Convert Excel 2 PDF: Excel to PDF Converter
Convert an Image 2 PDF: Image to PDF Converter
Convert HTML 2 PDF: HTML to PDF Converter
More Tools: PDF Converter
Great video, what if the name has space (first name and surname) how do you stop it saving with % signs in the name. Also – what if data in excel is too big for one row and you need to merge 2 rows to see the data – how do you include merged rows in the macros?
This is very useful. I will use the code and practice designing my report. This will save time from creating individual pdf which took me 2 days to create manually for more than 1400 students. Thanks.
Include a msgbox at the end to notify when the code is done
Killer dude, ty. I ported this to work for my application inside an hour. One thing I found was to ensure the cell dimensions in the output form will fit the incoming text. My pdf generator threw a fit and output garbage until I spent more time formatting the cells.
Geek Decoders – Power BI Learning Thank you for your help so far, please I want all this looping process but I want the data to be saved as Jpeg instead of PDF, kindly help me with the VBA Code please.
Is there a way I can attach the respective pdf in a column against the row using a hyperlink to the pdf just created?
Hi! Thanks for sharing your code. So I used it with my file and it is giving me a 'Run-time error '1004': Application-defined or object-defined error. Here is the code I used:
Sub ExportingPDF()
Dim detailsSheet As Worksheet
Dim reportSheet As Worksheet
Set reportSheet = ActiveWorkbook.Sheets("Template")
Set detailsSheet = ActiveWorkbook.Sheets("Data")
For i = 2 To 44
SApplicant_Number = detailsSheet.Cells(i, 1)
SDescribe_current_position = detailsSheet.Cells(i, 2)
SCareer_in_5to10years = detailsSheet.Cells(i, 3)
SChallenges_related_to_leadership = detailsSheet.Cells(i, 4)
SHow_workshop_will_help = detailsSheet.Cells(i, 5)
SActions_towards_inclusion = detailsSheet.Cells(i, 6)
reportSheet.Cells(3, 2).Value = SApplicant_Name
reportSheet.Cells(4, 2).Value = SDescribe_current_position
reportSheet.Cells(5, 2).Value = SCareer_in_5to10years
reportSheet.Cells(6, 2).Value = SChallenges_related_to_leadership
reportSheet.Cells(7, 2).Value = SHow_workshop_will_help
reportSheet.Cells(8, 2).Value = SActions_towards_inclusion
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"C:WSLW" & SApplicant_Name, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next i
End Sub
Thanks for your help!
what if we have pictures on the row, can it works?
how to insert separate images to each pdf files?
This is great, thank you! I have been looking for it for so long! One quick question, it is possible to create a PPT slide instead of a PDF file? Second question: Could be possible to have different image by each observation (each row)?
Thanks!! If i want to change the name of the exported PDF so that the extension is not in de documents name (now it is something similar to Dapp & Sname), how do i do that?
Never mind lol I figured it out I like and subscribed to help your channel Thanks for the great code
Thanks really useful.. I want all 20 row sheet to be created as single pdf
Hi
Just found your video! Any idea why I keep getting "error while printing?"
Hi, I have a picture in my file(from a url), but I can’t get it to appear in the design sheet, so it shows in the pdf. Do you have any tips to fix this?
I have more than 100 rows data in excel sheet. I want to make pdf files from these data. I need 10 rows record on each pdf file. so for 100 rows data, there will make 10 pdf sheets consist of 10 rows records. Is there any loop which will make pdf 10 rows and then again next 10 rows and so on?
Hi, I need your help please.
How to generate a single pdf for all reports rather than multiple PDFs?
Could you please help
This is very helpful! Is there a way to make the i more dynamic? Currently it's defined as i = 2 to 20. What if the number of rows constantly changes?
Hi Geek thanks so much it is really helpful! I am using this to create invoices for the supplier. If there are multiple same supplier in one column, and I want to group them and export as one invoice, what can I do? Thank you!
Hi Sir, I am trying to create pdf per your video but I get error. Can I get your email address to share my file with you for assistance? Thank you
Hi. Great video and thank you. What if you wanted to have all of the generated PDFs attach and send as an email to a specified user?
This is the visual basic code:
'Copyrighted of geekdecorder
Sub ExportingPDF()
'Defining worksheets
Dim detailsSheet As Worksheet
Dim reportSheet As Worksheet
Set reportSheet = ActiveWorkbook.Sheets("Format")
Set detailsSheet = ActiveWorkbook.Sheets("Details")
'Looping the through each row
For i = 2 To 20
'Assigning values
SName = detailsSheet.Cells(i, 1)
SCommerece = detailsSheet.Cells(i, 2)
SEnglish = detailsSheet.Cells(i, 3)
SMaths = detailsSheet.Cells(i, 4)
STotal = detailsSheet.Cells(i, 5)
'Generating the output
reportSheet.Cells(3, 2).Value = SName
reportSheet.Cells(4, 2).Value = SCommerece
reportSheet.Cells(5, 2).Value = SEnglish
reportSheet.Cells(6, 2).Value = SMaths
reportSheet.Cells(7, 2).Value = STotal
'Save the PDF file
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
"D:app" & SName, Quality:=xlQualityStandard, _
IncludeDocProperties:=True, IgnorePrintAreas:=False, _
OpenAfterPublish:=False
Next i
End Sub