Excel VBA SaveAs "Read-only" PDF File - Stack Overflow

    1. Home
    2. Questions
    3. Tags
    4. Users
    5. Companies
    6. Labs
    7. Jobs
    8. Discussions
    9. Collectives
    10. Communities for your favorite technologies. Explore all Collectives

  1. Teams

    Ask questions, find answers and collaborate at work with Stack Overflow for Teams.

    Explore Teams Create a free Team
  2. Teams
  3. Ask questions, find answers and collaborate at work with Stack Overflow for Teams. Explore Teams

Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

Get early access and see previews of new features.

Learn more about Labs Excel VBA SaveAs "Read-only" PDF file Ask Question Asked 2 years, 5 months ago Modified 2 years, 5 months ago Viewed 603 times 0

The following code successfully saves an excel sheet as PDF. I would like to save it as a file, that can be opened by everyone, but not edited with the "fill and sign" feature, that is provided by Adobe Acrobat Reader DC. I have tried to simply add the following, but that does not work:

Attributes:=vbReadOnly

Here is the rest of the code:

Dim sPath As String sPath = "O:\" With Worksheets("Sheet 1") .ExportAsFixedFormat _ Type:=xlTypePDF, _ Filename:=sPath & UserForm.TextBox1.Value & ".pdf", _ Quality:=xlQualityStandard, _ IncludeDocProperties:=True, _ IgnorePrintAreas:=False, _ OpenAfterPublish:=False End With Share Improve this question Follow asked Jan 24, 2022 at 8:34 MarkAKE's user avatar MarkAKEMarkAKE 452 silver badges8 bronze badges 0 Add a comment |

1 Answer 1

Sorted by: Reset to default Highest score (default) Trending (recent votes count more) Date modified (newest first) Date created (oldest first) 1

You should be able to use SetAttr after saving.

SetAttr "c:\path\yourfilename.pdf", vbReadOnly Share Improve this answer Follow answered Jan 24, 2022 at 12:00 ashleedawg's user avatar ashleedawgashleedawg 21.2k9 gold badges78 silver badges113 bronze badges 1
  • not working, I´m still able to fill&sign the pdf – MarkAKE Commented Jan 24, 2022 at 16:20
Add a comment |

Your Answer

Reminder: Answers generated by artificial intelligence tools are not allowed on Stack Overflow. Learn more

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid …

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.

Draft saved Draft discarded

Sign up or log in

Sign up using Google Sign up using Email and Password Submit

Post as a guest

Name Email

Required, but never shown

Post Your Answer Discard

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.

  • Featured on Meta
  • We spent a sprint addressing your requests — here’s how it went
  • Upcoming initiatives on Stack Overflow and across the Stack Exchange network...
  • What makes a homepage useful for logged-in users
  • The [lib] tag is being burninated
2 saving as PDF file on VBA return "Document not saved" error 1 store excel sheet as PDF on desktop 0 Using Excel VBA saveas function to save as PDF with user interaction 2 VBA “Save to PDF” saves even on cancels 2 Excel Save As PDF And Overwrite Existing 0 saving excel as pdf in active directory 0 Saving Excel Sheet as PDF 1 Save PDF from excel dynamically 0 Save as pdf using Mac Excel VBA 0 Writing and Saving to a PDF with VBA

Hot Network Questions

  • A manifold whose tangent space of a sum of line bundles and higher rank vector bundles
  • Air magic only used to decrease humidity and improve living conditions?
  • If I Trace "Pickup", will I pickup?
  • Do you always experience the gravitational influence of other mass as you see them in your frame?
  • Weather on a Flat, Infinite Sea
  • Can the differential be unitless while the variable have an unit in integration?
  • Rolling median of all K-length ranges
  • Two Sinus Multiply and Add
  • Job talk Q&A: handling the room vs. being respectful
  • It was the second, but we were told it was the fifth
  • Would this telescope be capable to detect Middle Ages Civilization?
  • Dual citizenship with USA & South Africa and exited South Africa on wrong passport (USA). What passport do I use to reenter SA?
  • What is the correct translation of the ending of 2 Peter 3:17?
  • Manga/manhua/manhwa where the female lead is a princess who is reincarnated by the guard who loved her
  • Improve spacing around equality = and other math relation symbols
  • Transferring at JFK: How is passport checked if flights arrive at/depart from adjacent gates?
  • Can a country refuse to deliver a person accused of attempted murder?
  • How to solve the intersection truncation problem of multiple \draw[thick, color=xxx] commands by color?
  • Question about NMAP HTTP Verb Tampering
  • Is the text of a LLM determined by a random seed?
  • Star alliance lounge at Luxembourg?
  • Would it be moral for Danish resitance in WW2 to kill collaborators?
  • Who is the woman who speaks when the Ravagers stop the Benatar?
  • ForeignFunctionLoad / RawMemoryAllocate and c-struct that includes an array
more hot questions Question feed Subscribe to RSS Question feed

To subscribe to this RSS feed, copy and paste this URL into your RSS reader.

lang-vb

Từ khóa » Visual Basic Excel Save As Pdf