Link to home
Start Free TrialLog in
Avatar of Peter H.
Peter H.Flag for Canada

asked on

word automation decrypt document file

I have a number of old word documents that I need to migrate to pdf but first I need to save them as DOCX but I want to save them without the Encryption password (which I have).

Anybody know how to do this?
Avatar of Paul Sauvé
Paul Sauvé
Flag of Canada image

Remove password protection from a Word document

Use the password to open the document.

Click the Microsoft Office Button  Office button image , point to Prepare, and then click Encrypt Document.

In the Encrypt Document dialog box, in the Password box, delete the encrypted password, and then click OK.

Save the file.
https://support.office.com/en-us/article/Password-protect-documents-workbooks-and-presentations-ef163677-3195-40ba-885a-d50fa2bb6b68
Avatar of Peter H.

ASKER

I need to create a program to do this in C# or VFP, it is easy enough to do this manually.
I need to create a program to do this in C# or VFP, it is easy enough to do this manually.
i guess i didn't  guess what you wanted―i don't really program that well :-(
Is there any reason that you can't use VBA?
What I need to do is use word automation from within an application.
Avatar of jrbbldr
jrbbldr

Keep in mind that I have not done this myself, so what I recommend is based solely on how I generally approach VFP Automation of Office, but it might only be worth everything you had to pay for it......

I'd start in Word without VFP.

1. Open the password protected document into Word
2. Find out how to, within Word, do a SaveAs with No Password protection.
a. That might be to Remove the Password protection first
b.  And then to do your SaveAs...

Now that you know how to do it in Word, set up to record a Macro and do the same steps again.
Now Stop recording the Macro and review it through Edit
It should show you the steps necessary for your VFP Automation to do for the 2nd part of the task.

Now on to the first part - using VFP Automation to open the password protected document
1. Create something like      oWord = CREATEOBJECT("word.application")
2. Now Open your Document   oDoc = oWord.Documents.Open(oDocument,,,,,)   && Apparently the 5th parameter can be your document's Password
Once you can Open the password protected document, continue with your VFP Automation code to implement what you learned above about saving the document.

If you get it working, we might like to see your VFP Automation code.

Good Luck
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.