0% found this document useful (0 votes)
90 views2 pages

MACROS

This VBA macro encrypts PDF files listed in a worksheet. It gets the file names and passwords from columns A and B, determines the last row of data, and uses a for loop to call an encryption program on each file, passing the file name and password as arguments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
90 views2 pages

MACROS

This VBA macro encrypts PDF files listed in a worksheet. It gets the file names and passwords from columns A and B, determines the last row of data, and uses a for loop to call an encryption program on each file, passing the file name and password as arguments.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Option Explicit

Sub Encrypt_PDFs()

Dim file_name As String


Dim row_number As Long, last_row As Long
Dim wsSheet1 As Worksheet

Set wsSheet1 = ThisWorkbook.Worksheets("Sheet1")

With wsSheet1
last_row = .Cells(Rows.Count, "A").End(xlUp).Row

For row_number = 2 To last_row


Call Shell("encrypt_pdf.exe " & Chr(34) & .Cells(row_number, "A").Value & Chr(34) &
" " & Chr(34) & .Cells(row_number, "B").Value & Chr(34), vbNormalFocus)

Next row_number

End With

Set wsSheet1 = Nothing

End Sub

---------------------------------------------

Option Explicit

Sub Encrypt_PDFs()

Dim file_name As String


Dim row_number As Long, last_row As Long
Dim wsSheet1 As Worksheet

Set wsSheet1 = ThisWorkbook.Worksheets("Sheet1")

With wsSheet1
last_row = .Cells(Rows.Count, "A").End(xlUp).Row

For row_number = 2 To last_row


Call Shell("encrypt_pdf.exe " & Chr(34) & .Cells(row_number, "A").Value & Chr(34) &
" " & Chr(34) & .Cells(row_number, "B").Value & Chr(34), vbNormalFocus)

Next row_number

End With

Set wsSheet1 = Nothing

End Sub

--------------------------------------------------

Sub Encrypt_PDFs()

Dim file_name As String


Dim row_number As Long, last_row As Long
Dim wsSheet1 As Worksheet

Set wsSheet1 = ThisWorkbook.Worksheets("Sheet1")

With wsSheet1
last_row = .Cells(Rows.Count, "A").End(xlUp).Row

For row_number = 2 To last_row


Call Shell(ActiveWorkbook.Path & "\" & "encrypt_pdf.exe " & Chr(34)
& .Cells(row_number, "A").Value & Chr(34) & " " & Chr(34) & .Cells(row_number,
"B").Value & Chr(34), vbNormalFocus)

Next row_number

End With

Set wsSheet1 = Nothing

End Sub

You might also like