Convert Excel File to Password Protected PDF File with VBA

How to convert an Excel File to a password protected PDF file with VBA automatically free of cost. Saving an Excel File with password as a PDF file does not password protect the PDF file. Also exporting the Excel file as a PDF file does not password protect the final PDF file. It can be easily opened by Acrobat reader without a password. The method shown in our video ensures that the converted Excel file is a password protected file. It does not require expensive third-party software. In fact, the complete process of creating a password protected PDF file from an Excel worksheet is totally free.

Watch the video below.



Watch this video on YouTube.

Here’s the VBA code or macro:

Sub protectPDFWithPassword()
ActiveSheet.PrintOut ActivePrinter:=”PDFCreator”

End Sub

Further reading:

VBA: Excel / Word to PDF Encrypted / Password Protected


Published by

Dinesh Kumar Takyar

Welcome to! My aim is to help you learn MS Excel including VBA. I always felt that a good way to learn something was to find solutions to problems in that domain. That is why I share these Excel videos with you. Mostly these are questions asked during my corporate training sessions. I've been training individuals and companies in computers since 1991. I did my B. Sc. (Vordiplom), M. Sc. (Diplom) and Ph.D. (Dr. rer. nat.) from Hamburg, Germany. The best thing about solving some of my visitor's questions is that I also gain new insights. For more Excel VBA solutions you may like to visit my YouTube channel: For a structured Excel VBA training course online you can visit:

One thought on “Convert Excel File to Password Protected PDF File with VBA”

  1. Hello Dinesh Sir,

    It was very useful to see your videos on excel formulas and VBA. i generally follow your videos.

    Well i required to know that can we have something like having a delete or copy function in effect after a specific time is elapsed. For eg. if i need to copy the contents from one column to another after every 5 seconds. This is for those excel sheets which are continuosly changing data in real time as that is connected to a software like ECG machine, Share Trading etc.

    Would like to hear from you.


Leave a Reply

Your email address will not be published. Required fields are marked *