Export All Sheets to PDF - Excel VBA

preview_player
Показать описание
Create a macro in Excel to export all sheets to PDF.

This video walks you through the Excel VBA code used to export all sheets to PDF. The code contains a loop and the use of the ExportAsFixedFormat method for the Worksheets object.

Creating a macro makes this seemingly repetitive process happen at the click of a button.

All PDF's are saved in the same folder to the Desktop. Get the code from the link above in this description. Copy it and adapt it to your needs.

Find more great free tutorials at;

*** Online Excel Courses ***

Connect with us!
Рекомендации по теме
Комментарии
Автор

how can we exports all sheets in a single PDF file? we dont know the number of sheets or the names. they change in each file.

ehsanvahabzadeh
Автор

What if you want to retain the existing page layout of each sheet?

nicogor
Автор

Is there a way to stipulate where you need each PDF to be filed? The project I am working on involves about 60 worksheets that must be saved as PDF, but each PDF must be saved in its own separate folder.

Nandoslc
Автор

I have an excel sheet that I need to produce the PDF file but I need it not to overwrite the one this code creates. Every time I hit the pdf button to create another one it replace the previous one. How would I get it to create a new one each time. I do have it saving with the work order number right now and that would be great if I can save the pdf with the work order number also. My form automatically generates a new number using the (+1) so it would go from 100 to 101 and so-on as I save the files. I would like to do that with pdf also. Here is the excel code used to create the excel  Range("K1").Value = Range("K1").Value + 1

garlandburton
Автор

Great vid. Everything is working, the folder is created on my desktop, and the sheets are being exported as PDF and named correctly.The only problem is that the pdfs are being saved on my desktop next to (not inside of) the PDFs folder.Any thoughts?

jiliff
Автор

When I export multiple pages as pdf I see pages automatically gets zoom in none please sughest

mujeebuddinsarfaraz
Автор

Run-time error "75" - Path/file access error. What does it mean? Could you help me to find the error? if I click "debug", it underlines MkDir FolderPath

rictraverso
Автор

Can we use command button and check boxes to choose what to print?

Baha_e
Автор

hello sir, how about if we want to export only unhidden sheets in a workbook, where book has both hidden and unhidden sheets, please help me with this, it would be of great help 😊

satyenpurohit
Автор

Hello if I want to send the excel to my chief, so that he can save as pdf the problem is the path. I have my user, he has his, How can I solve? thanks

LorenzoM
Автор

Does this code work anymore? I've copied it out and changed the path etc.. but it won't work.. it's saying the bit with Worksheets(i).ExportAs FixedFormat Type”=xlTypePDF, Filename:=FolderPath & “\” & _Worksheets(i).Name, openafterpublish:=False is not right.. any help?

AmyMichaelsmusic
Автор

Hi - I am using the code as is but it throws error MkDir FolderPath. below is the code I am using. Can you please help?

Option Explicit

Sub ExportAsPDF()
Dim FolderPath As String
Dim i As Integer

FolderPath =

MkDir FolderPath

For i = 1 To Worksheets.Count

Type:=xlTypePDF, Filename:=FolderPath & "\" & _
Worksheets(i).Name, openafterpublish:=True

Next

MsgBox "PDF scucessfully reated"


End Sub

FYI .. the Fill_Rate is already created on my computer. Also, I have 10 sheets in my file and I want to save only 3 as PDF, how do I do that? Do I have to name each file or can I just give print open sheets in the file?

Thanks,
Rahman

RahmanShaikk
Автор

When I ran this code, it kept showing “ Sub or Function not defined”. Is there anyway I can solve it?

weixue
Автор

link not working
can you refresh the link please

AbuTalha-eopr