Can someone please explain to me the workflow to password protect more than 1000 PDF’s that are in a folder with different passwords from an Excel file?
In the excel I have 2 columns, NumberAndName and Password, each password is assigned to the number (no similar name, for ex: the same password for those 3: 101 Pete, 101 Josh, 101 Carmen but a different password for those 3: 102 Raj, 102 Alex, 102 Hannah).
As i cannot install anything on this pc, can you please guide me here/in private please?
Hello @vlad.tanase94 ,
Firstly, Vlad you should have PDF name in a variable. Later, You need to extract The Number in your PDF Name, If it is always first 3 number than you can cut with SubString(0,3). After you got the Number you can search The Number in Column A(NumberAndName) and you can get Column B(Password) value. As code you can use the Linq code.
EQ :
ThePasswordValue : dtPasswordExcel.AsEnumerable().where(function(rw) rw.item(0).toString.Contains(TheNumberVariable)).select(function(rw) rw.item(1).ToString).Tolist().item(0).tostring
From Here you can use ThePasswordValue as your password. It will dynamicly changed for PDF File Name.
Here is Example : Main.xaml (12.2 KB)
It’s crucial that the filenames correspond to the NumberAndName in your Excel file. For instance, if the Excel has an entry 101 Pete, there should be a PDF file named 101 Pete.pdf in your folder.
- Use Read Range Activity (Store the data in DataTable, name as DT)
- Use For Each File in Folder Activity (Filter:
"*.pdf") - Use Assign Activity for storing Password and use below expression
If(DT.AsEnumerable().Any(Function (x) x("NumberAndName").ToString().Equals(CurrentFile.Name)), DT.AsEnumerable().Where(Function (x) x("NumberAndName").ToString().Equals(CurrentFile.Name)).CopyToDataTable().Rows(0)("Password").ToString(),String.Empty)
- Use Read PDF Text Activity and Pass the PdfPassword in Properties.
Hope it’ll helps you ![]()
Cheers !!
Hello @Murat_Kilic , thank you for you response!
The number is actually an 11 digit number (was easier to use “3” as an example) but i think i can type (0,11).
I am lost a bit at Linq code, as at the moment i don’t know what this mean, also a bit lost at “The password value:”.
If this isn’t too much to ask, can you please show me a screenshot or picture of how the workflow should look like?
thank you again for your response ![]()
hello, thank you very much for you response!
yes, the exact name of the pdf is in the excel
I don’t have the “for each file in folder” activity and my manager doesn’t let me install packages… is there another way?
You can Try For Each Loop
- Use For Each Activity
Directory.GetFiles("C:\Users\nahmad\Downloads\Test", "*.pdf")
- Change your Folder Path
- Do Change in Above Expression - Replace
CurrentFile.Namewith Path.GetFileName(CurrentFile)
Happy Automation ![]()
I will give it a try when the pc is available and come back with an answer.
Thank you very much! ![]()
hi, this looks like it opens PDF files from that folder using the password from my list…
i need to add the password from my list to the pdf to protect it, so anyone that has that password can open the pdf and who doesn’t know it cannot open the pdf…
can you guide me through, please? ![]()
Okay, So you want to set the password to the pdf from the list in your Excel.
Then just Replace the Read PDF Text with Manage PDF Password Activity
- Pass the Pdf File Path
- Pass the Password from your Excel list into NewUserPassword i.e stored in PdfPassword variable.
Look below image for reference:
Hope it’ll helps you ![]()
Cheers !!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.


