How to Password Protect PDF Files using VBA

Поділитися
Вставка
  • Опубліковано 7 лип 2021
  • This is probably one of the most requested topics I got from my mail merge automation video. In this tutorial, we are going to look at how to use VBA in Excel to password protect a list of PDF files.
    Download the command line encryption tool: learndataanalysis.org/pdf-enc...
    Buy Me a Coffee? Your support is much appreciated!
    -------------------------------------------------------------------------------------
    🔑PayPal Me: www.paypal.me/jiejenn/5
    🔑Venmo: @Jie-Jenn
    💼Join Robinhood with my link and we'll both get a free stock 🤝 join.robinhood.com/jiej6
    Support my channel so I can continue making free contents
    ---------------------------------------------------------------------------------------------------------------
    Patreon: / jiejenn
    By shopping on Amazon → amzn.to/2JkGeMD
    More tutorial videos on my website → LearnDataAnalysis.org
    Business Inquiring: UA-cam@LearnDataAnalysis.org
    #VBA #PDF #Encryption

КОМЕНТАРІ • 98

  • @jiejenn
    @jiejenn  2 роки тому

    There is a space after the exe path. ".exe " -> yes
    ".exe" -> no

  • @shinli3632
    @shinli3632 2 роки тому

    This is very helpful, thank you very much for sharing

  • @ekayuanita3026
    @ekayuanita3026 Рік тому

    very useful. thank you

  • @cfisher3428
    @cfisher3428 Рік тому

    thanks, this is very useful

  • @kmdafzal
    @kmdafzal Рік тому

    Very much useful

  • @sergioaguirre3295
    @sergioaguirre3295 2 роки тому

    You are amazing!!! This helps me a lot! Thanks!!!

    • @jiejenn
      @jiejenn  2 роки тому +1

      I am guessing you got your issue resolved?

    • @sergioaguirre3295
      @sergioaguirre3295 2 роки тому

      Yes! I was able to solve it, you have no idea how you help me with this tutorial

  • @MrMarek27
    @MrMarek27 2 роки тому

    I want to use your method but i cant. Excel show Error "Object doesn't support this property or method". Do you know why? I have Office 2019 Home edition.

  • @aidianyingren
    @aidianyingren Рік тому

    Hi thank you for the program. However when I ran it, it does not automatically fill the PDFEncrypt menu. I need to type in. Do you know why? Thanks

  • @abdelrhmanmohamed678
    @abdelrhmanmohamed678 Рік тому

    Can you share the decompiled python code , I'm seeking to encrypt the pdf file with two passwords (owner and user) ?

  • @fksoftware
    @fksoftware 2 роки тому +1

    Excellent tool and thanks for sharing. Can we use the same tool to encrypt pdf to prevent editing or copying not password to open?

    • @jiejenn
      @jiejenn  2 роки тому +1

      I don't think that's possible as far as I know.

  • @onemusic3924
    @onemusic3924 2 роки тому

    How to fix the Run-Time error 5 Invalid procedure called argument?

  • @nurulsyuhada6493
    @nurulsyuhada6493 Рік тому

    Hi! If I send the encrypted PDF files via email/telegram to many recipients, will the password work?

  • @amitmishra1513
    @amitmishra1513 Рік тому

    Thanks excellent Video but it had encrypted only one file out of 3 when I run first time and 2nd time nothing happen

  • @DeadbeatGaming1705
    @DeadbeatGaming1705 Рік тому

    Hey, can i merge this module into a separate module so that the mail merge, creation and encryption could be done together rather than seperate modules??

  • @nesyfitria4610
    @nesyfitria4610 2 роки тому

    hi, can I use other software rather that encrypted_pdf.exe such a password tool?

    • @jiejenn
      @jiejenn  2 роки тому

      Sure. If you do a Google search you should find a few 3rd party tools to encrypt PDD files.

  • @ShrajanShetty
    @ShrajanShetty 2 роки тому +3

    Hi,
    could you provide the source code for this please?

  • @kentlee3928
    @kentlee3928 2 роки тому

    Hi. It shows
    "Run-time error "9": Subscript out of range
    When I run the macro. Please assist. Thank you!

    • @jiejenn
      @jiejenn  2 роки тому

      Looks like the program cannot read your table properly.

  • @abhishodhds5322
    @abhishodhds5322 Рік тому +1

    Hi jie
    Can you make a video on creation of exe file

  • @dominic2534
    @dominic2534 Рік тому

    Hi, I am receiving the message "runtime error'53': file not found". I have seen other comments where you said to specify the file location in a variable to point to the binary. Can you explain how to do that? Where should it be included in the code?

    • @jiejenn
      @jiejenn  Рік тому

      Makes sure the spaces are in the correct places.

    • @dominic2534
      @dominic2534 Рік тому

      @@jiejenn thank you for replying. The file name I entered like you did in your video. I do not know where to put the folder location.

  • @VBAbyMBA
    @VBAbyMBA 2 роки тому

    Is it possible for vba to encrypt while exporting pdf without using third-party software

    • @jiejenn
      @jiejenn  2 роки тому

      I don't think that's possible at this point. If you do find a way, do let me know and I will buy you a coffee.

  • @ramachandramurthykota4841
    @ramachandramurthykota4841 Рік тому

    I am getting Runtime Error 1004 for this code Call Shell("encrypt_pdf.exe " & Chr(34) & .Cells(row_number, “B”).Value & Chr(34) & " " & Chr(34) & .Cells(row_number, "F").Value & Chr(34), vbNormalFocus)
    Can some one help me in cracking this error please

  • @terencexie2601
    @terencexie2601 2 роки тому

    what if i have a few filepath to encrypt example: filepath 1 to filepath 6?

    • @jiejenn
      @jiejenn  2 роки тому

      Update your file paths?

  • @purplemoorselle
    @purplemoorselle 2 роки тому

    Hi, this looks amazing! But is it possible to apply the macro to the pdfs instead of the .exe file?

    • @jiejenn
      @jiejenn  2 роки тому +1

      Not sure if I follow your question.

    • @purplemoorselle
      @purplemoorselle 2 роки тому

      @@jiejenn uhm but you have .exe file to which u applied the macro ight? Just wanted to know if this can be replicated to pdf files directly.

    • @jiejenn
      @jiejenn  2 роки тому

      The macro calls the exe file. VBA doesn't have a defaulf library to work with PDFs.

    • @purplemoorselle
      @purplemoorselle 2 роки тому

      @@jiejenn I see. So it means I need to create a .exe file first?

  • @mariomakarawo
    @mariomakarawo Рік тому +1

    Hi, can u help me, the application can’t working, i got notif
    encrypt_pdf.exe: error: following arguments are required: password
    Pls help to solve. Thank you 🙏🏻

  • @cendydahinog1520
    @cendydahinog1520 Рік тому

    i put your code and download encrypt_pdf but nothing happen😢.. can u help me ?

  • @neerajburra
    @neerajburra Рік тому

    I am getting error 9, subscript out of range. Can anyone help me???

  • @Smiledaiykub
    @Smiledaiykub 2 роки тому

    Hi, Do you have encrypt_pdf for mac version?

    • @jiejenn
      @jiejenn  2 роки тому +1

      Only Windows.

  • @ve6571
    @ve6571 Місяць тому

    where can we get encrypt_pdf.exe file

  • @raymarc3353
    @raymarc3353 3 роки тому

    Hi, I'm getting a debug error in line 5, set...kindly help I'm using office 19

    • @jiejenn
      @jiejenn  3 роки тому

      Are you using Windows or MacOS?

    • @khanhhuynh5557
      @khanhhuynh5557 2 роки тому +3

      Hi, Just add the folder path where you put file "encrypt_pdf.exe" in the call command. It will solve the problem.
      E.g. Call Shell(ActiveWorkbook.Path & "\" & "encrypt_pdf.exe " & Chr(34)...

    • @ThanhNguyen-dw4il
      @ThanhNguyen-dw4il Рік тому

      ​@@khanhhuynh5557 It is run but pdf output file is no password. Maybe file ecrypt_pdf is not working.

  • @sushenranjandas451
    @sushenranjandas451 Рік тому

    Hello sir, Is there any way to decrypt pdf password using macro, like this?

    • @jiejenn
      @jiejenn  Рік тому +1

      Good suggestion. Let me put up a follow up video in the future.

    • @sushenranjandas451
      @sushenranjandas451 Рік тому

      @@jiejenn Thank you.

  • @jessefreitag5374
    @jessefreitag5374 Рік тому

    Hello, I copied the code exactly written, installed the encryption tool and when I run the macro, nothing happens. I open the pdf and there is no password. Do you have any advice?

    • @jiejenn
      @jiejenn  Рік тому

      Hard to tell without looking at your code.

    • @jessefreitag5374
      @jessefreitag5374 Рік тому

      ​@@jiejenn
      Code is below. Same as the video. I am saving my encrypt_pdf.exe , my excel file, and my pdf in the same path. The Call Shell("") command does not open the command line tool and when I run the command line tool, it opens quickly and immediately shuts. I even tried running as administrator.
      Sub PasswordProtect()
      Dim file_name As String
      Dim row_number As Long, last_row As Long
      Dim wsList As Worksheet
      Set wsList = ThisWorkbook.Worksheets("List")
      With wsList
      last_row = .Cells(Rows.Count, "A").End(xlUp).Row
      For row_number = 2 To lastrow
      Call Shell("encrypt_pdf.exe " & Chr(34) & .Cells(row_number, "A").Value & " " & Chr(34) & .Cells(row_number, "B").Value & Chr(34), vbNormalFocus)
      Next
      End With
      End Sub

    • @jessefreitag5374
      @jessefreitag5374 Рік тому

      I am not getting an error, just nothing happens and I believe someone below has had the same issue in recent months. Can you please look into this and see if it works on your end still? Would be greatly appreciated!

  • @LoneIcon
    @LoneIcon 2 роки тому

    hi, i tried it today and i got this error "runtime error'53': file not found"
    The error is pointing to Call Shell("encrypt_pdf.exe" ...

    • @jiejenn
      @jiejenn  2 роки тому +1

      The error is due to VBA cannot locate the binary.

    • @Indie-Digger
      @Indie-Digger 2 роки тому

      @@jiejenn Is there a way to let VBA to locate the binary?

    • @jiejenn
      @jiejenn  2 роки тому

      You specify the file location in a variable to point to the binary.

    • @Indie-Digger
      @Indie-Digger 2 роки тому

      @@jiejenn Thx for replying so fast,, it's really my first time to use VBA.. would you please tell me how to set the location in the variable?

    • @sergioaguirre3295
      @sergioaguirre3295 2 роки тому

      I’m facing the same issue

  • @floalas
    @floalas 2 роки тому

    Hello JieJenn, I don’t have Python Exe file & I know it will not work. How shall I get it from you?

    • @jiejenn
      @jiejenn  2 роки тому

      Not sure if I understand your question.

    • @floalas
      @floalas 2 роки тому

      In your video you mentioned create using python. There was an . Exe file on your video. How can I get this file ? The script won’t work without this file.

    • @jiejenn
      @jiejenn  2 роки тому

      @@floalas I used Python to create the command line tool. You don't need Python to use the tool.

    • @floalas
      @floalas 2 роки тому

      I don’t have the encrypt_pdf.exe. I tried to run the script got error.

    • @jiejenn
      @jiejenn  2 роки тому

      Ok.

  • @sifatullah8071
    @sifatullah8071 2 роки тому

    Can anyone share this code to me ?

  • @erikachen5747
    @erikachen5747 2 роки тому

    How can I create the file of pdf.exe??Thank you.

    • @jiejenn
      @jiejenn  2 роки тому

      I'm not following your question.

    • @erikachen5747
      @erikachen5747 2 роки тому

      There is a file named of “encrypt_pdf.exe.
      You mentioned that is created using Python and will share the source code in another tutorial.

    • @jiejenn
      @jiejenn  2 роки тому

      Oh yeah. I haven't create the tutorial for that. Been busy.

    • @susmithasunil6611
      @susmithasunil6611 2 роки тому

      @@jiejenn please share the tutorial for the same

    • @yashkumargupta7102
      @yashkumargupta7102 2 роки тому

      @@jiejenn Hi Jie, Can you please share the Tutorial for encrypt_pdf.exe

  • @DrJohnners
    @DrJohnners Рік тому

    Excellent tool! Many thanks. One thing i was wondering is why is the .exe so big, I'm guessing it's because there are a number of heavy runtimes that you need?

    • @jiejenn
      @jiejenn  Рік тому +1

      This tool was packaged using the old Python library called pyinstaller, which the packaging mechanism wasn't very efficient. They have since improved the packaging mechanism, and the executable file size is much smaller.
      I probably need to repackage this app when I get a chance.

  • @chiragpatel1706
    @chiragpatel1706 2 роки тому +1

    File not found error ??

    • @jiejenn
      @jiejenn  2 роки тому

      Just tested, it is there.

    • @chiragpatel1706
      @chiragpatel1706 2 роки тому +1

      @@jiejenn Yes all file are in same folder 🤔( runtime error'53': file not found)

    • @sergiocastro1561
      @sergiocastro1561 2 роки тому

      same error here, file not found error 53

    • @akashrawat5329
      @akashrawat5329 2 роки тому

      @@jiejenn Please can you help resolve this error.

    • @khanhhuynh5557
      @khanhhuynh5557 2 роки тому +2

      Hi, Just add the folder path where you put file "encrypt_pdf.exe" in the call command. It will solve the problem.
      E.g. Call Shell(ActiveWorkbook.Path & "\" & "encrypt_pdf.exe " & Chr(34)...

  • @sifatullah8071
    @sifatullah8071 2 роки тому

    Can you send VBA code sir ?

    • @jiejenn
      @jiejenn  2 роки тому

      Maybe type it out yourself?

  • @priyanthagamini3860
    @priyanthagamini3860 Рік тому

    Exactly Good ❤️❤️❤️ would you please give me the link for "encript_pdf.exe"

  • @onemusic3924
    @onemusic3924 2 роки тому +1

    Can you send VBA code sir ?

    • @jiejenn
      @jiejenn  2 роки тому

      Maybe type it out yourself?