Write-Protect an Excel Generated PDFs: HOW TO DO IT?

poizones

New Member
Joined
Mar 30, 2018
Messages
7
I have deployed a Daily Time Record (DTR) system to the field using excel vba. Unfortunately, there are these colleagues who are not so faithful to their work. I have found out that some of them simply edited the PDF generated DTR. Can anyone help me with this?

Here are the codes that I have been using for almost 2 years already.
Code:
Sub SavePDF()

Dim sRange1 As String
Dim sRange2 As String
Dim sPace As String
Dim rngRange As Range
Dim strFilename, strDirname, strPathname, strDefpath As String
 On Error Resume Next

sRange1 = ActiveSheet.Range("F9")
sRange2 = ActiveSheet.Range("Z13")
sPace = (" DTR ")

strDirname = sRange1 + sPace + sRange2

Set rngRange = Worksheets("DTR").Range("C6")

strFilename = rngRange.Value & Format(Now(), " mmddyyyy")
strDefpath = Application.ActiveWorkbook.Path

If IsEmpty(strDirname) Then Exit Sub
If IsEmpty(strFilename) Then Exit Sub
If rngRange.Value <= "" Then Exit Sub

MkDir strDefpath & "\" & strDirname
strPathname = strFilename
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=strDefpath & "\" & strDirname & "\" & strFilename & ".pdf" _
    , Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
    :=False, OpenAfterPublish:=False2
    
End Sub

Thank you so much. Any help is appreciated very much.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
Cross posted https://www.excelforum.com/excel-pr...l-generated-pdf-how-to-do-it.html#post5122168

While we do not prohibit Cross-Posting on this site, we do ask that you please mention you are doing so and provide links in each of the threads pointing to the other thread (see rule 13 here along with the explanation: Forum Rules).
This way, other members can see what has already been done in regards to a question, and do not waste time working on a question that may already be answered.
 
Upvote 0

Forum statistics

Threads
1,216,075
Messages
6,128,668
Members
449,463
Latest member
Jojomen56

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top