Encrypt a Word document in VBA

I want to create a macro that in certain situations will encrypt the current 
document such that when the document is saved and opened again, Word will ask 
for the password (similarly to the user selecting the Office Button -> 
Prepare -> Encrypt Document). 

Would someone tell me how this can be done?  Thanks for any help.

0
Utf
6/1/2010 2:19:01 PM
word.vba.general 1023 articles. 1 followers. Follow

3 Replies
3467 Views

Similar Articles

[PageSpeed] 18

To set a password ...

    ActiveDocument.Password = "whatever"

To save with a password ...

    ActiveDocument.SaveAs name_etc., Password:="whatever"

-- 
Enjoy,
Tony

 www.WordArticles.com

"JeffG" <JeffG@discussions.microsoft.com> wrote in message 
news:00FD01C1-E5E9-4D8B-98C2-28E616BDFFED@microsoft.com...
>I want to create a macro that in certain situations will encrypt the 
>current
> document such that when the document is saved and opened again, Word will 
> ask
> for the password (similarly to the user selecting the Office Button ->
> Prepare -> Encrypt Document).
>
> Would someone tell me how this can be done?  Thanks for any help.
> 

0
Tony
6/1/2010 3:43:21 PM
Thanks for the response.  That worked beautifully, but raises another 
question.  how good is the encryption and how easily can it be broken?

"Tony Jollans" wrote:

> To set a password ...
> 
>     ActiveDocument.Password = "whatever"
> 
> To save with a password ...
> 
>     ActiveDocument.SaveAs name_etc., Password:="whatever"
> 
> -- 
> Enjoy,
> Tony
> 
>  www.WordArticles.com
> 
> "JeffG" <JeffG@discussions.microsoft.com> wrote in message 
> news:00FD01C1-E5E9-4D8B-98C2-28E616BDFFED@microsoft.com...
> >I want to create a macro that in certain situations will encrypt the 
> >current
> > document such that when the document is saved and opened again, Word will 
> > ask
> > for the password (similarly to the user selecting the Office Button ->
> > Prepare -> Encrypt Document).
> >
> > Would someone tell me how this can be done?  Thanks for any help.
> > 
> 
> .
> 
0
Utf
6/2/2010 12:40:01 PM
If you use a strong password, it will be strong.  If you use a weak one, it 
will be weak.

The stronger the password, the stronger the protection.

-- 
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com

"JeffG" <JeffG@discussions.microsoft.com> wrote in message 
news:EC7C5616-1AAE-4AE4-A00B-74F099A15BC1@microsoft.com...
> Thanks for the response.  That worked beautifully, but raises another
> question.  how good is the encryption and how easily can it be broken?
>
> "Tony Jollans" wrote:
>
>> To set a password ...
>>
>>     ActiveDocument.Password = "whatever"
>>
>> To save with a password ...
>>
>>     ActiveDocument.SaveAs name_etc., Password:="whatever"
>>
>> -- 
>> Enjoy,
>> Tony
>>
>>  www.WordArticles.com
>>
>> "JeffG" <JeffG@discussions.microsoft.com> wrote in message
>> news:00FD01C1-E5E9-4D8B-98C2-28E616BDFFED@microsoft.com...
>> >I want to create a macro that in certain situations will encrypt the
>> >current
>> > document such that when the document is saved and opened again, Word 
>> > will
>> > ask
>> > for the password (similarly to the user selecting the Office Button ->
>> > Prepare -> Encrypt Document).
>> >
>> > Would someone tell me how this can be done?  Thanks for any help.
>> >
>>
>> .
>> 
0
Doug
6/2/2010 10:59:30 PM
Reply:

Similar Artilces:

Editing options disapear when document is changed to compatibility
I have an excel (2007) document with makro content that has been edited by other people. One of them changed the document to a shared document (compatibility mode) to be able to track changes. Now the document seems to be partially locked. I am hadly allowed to change any kind of formating or insert anything. How do I change back the document or get rid of whatever is blocking me from using many functions? tools/protection/unprotect sheet "Me" wrote: > I have an excel (2007) document with makro content that has been edited by > other people. One of them chan...

Referring to a range that has been copied (Excel-VBA)
Hi, Can anyone confirm if there is a way in VBA to refer to a range that has just been copied but that it is not the selected range? For example: I select Range A1:A2, I press Ctrl+C and dotted moving lines appear around A1:A2. Now, I move to any other cell, say B4. At this stage, A1:A2 remain highlighted with the dotted lines, so I understand that the Application "knows" of them, therefore how can I return their address through code? Selection.address will obviously not work as it is no longer the selected range...I looked within the Application object but could not fin...

Counting words............
How can I give the total of how many times a word appears in a column? -- Smokey_Vol ------------------------------------------------------------------------ Smokey_Vol's Profile: http://www.excelforum.com/member.php?action=getinfo&userid=29717 View this thread: http://www.excelforum.com/showthread.php?threadid=495182 have a look at =COUNTIF( -- Don Guillett SalesAid Software dguillett1@austin.rr.com "Smokey_Vol" <Smokey_Vol.20eapy_1135177209.4582@excelforum-nospam.com> wrote in message news:Smokey_Vol.20eapy_1135177209.4582@excelforum-nospam.com... > >...

how do you rotate a visio drawing in word?
It's easy to insert a visio drawing into Microsfot word, but it doesn't seem possible to rotate the drawing...? zoom out to see full page, hold ctrl key down, place cursor via mouse to corner of drawing page, see cursor pointer change to curved arrow, drag to rotate page, angle shows in bottom left corner of screen, angle accuracy controlled as usual. "TJ" <TJ@discussions.microsoft.com> wrote in message news:FAFD2CD7-C9A7-4F21-9425-42B9616A7BDC@microsoft.com... > It's easy to insert a visio drawing into Microsfot word, but it doesn't > seem > po...

the application microsoft (word, excel and powerpoint) quit unexpectedly
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel installed microsoft office 2008 in october 2008, and had no trouble. as of may/june 2009, i no longer wanted these icons (icons for word, excel and powerpoint) on my dock, and so removed. now when i try to open these applications, the message; the application microsoft word quit enexpectedly. mac os x and other applications are not affected. click relaunch to launch the application again. click report to see more details or send a report to apple. the report then says: Process: Microsoft Excel [319] Path: /Applicati...

Problem with vba directory function
Hi We have an access application that has a button when clicked opens an excel worksheet showing all exported data based on code The access sql system is in Citrix with a single front end copy. Here is the code part that is throwing the error for just one user. Rest all are working fine Dim strSourceFileName As String Dim WorkBookName As String strSourceFileName = "c:\CarLogOutPut\CarLogExportTemplate.xls" WorkBookName = "c:\CarLogOutPut\CarLogExport.xls" If Dir(strSourceFileName) = "" Then MsgBox "CarLogExportTemplate.xls doe...

Word Documents
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Intel Hi, How do I make tool bars appear automatically upon opening a new document? Each time I open a new or previously saved document I have to re-open my tool bar. I have been unable to find where I can make the tool bar freeze in place and open when I open documents. I am a college student with lots of papers to write. This gets cumbersome after a while. Please help. Thank you Wendy. Click the oval button at the right end of a document window to turn off Apple's poorly documented & unidentified 'minimize...

Compress pictures in word 2000
Hi How can i compress the pictures in my document using word 2000. I can not find it in format picture and am now at a loss -- Thank you for reading my post. Hopefully you can answer my querie ...

Lotus Documents in Excel
At my business, we use Lotus 1-2-3 for any of our worksheets. However, more and more of our customers are using Excel and no one really has Lotus. My boss was wanting to know if there was a way to transfer all of our Lotus Documents into an Excel spreadsheet instead of Lotus. Krissy, If they are simple, you can simply save them from 1-2-3 as Excel files. If they have macros, you're in for a rough time. HTH, Bernie MS Excel MVP "Krissy86" <Krissy86@discussions.microsoft.com> wrote in message news:22E83BAF-CBDD-409E-A376-2B8A1B9454A2@microsoft.com... > At my ...

how do you insert a document in words 2007
I need help inserting a document in Office 2007, please help. Insert - Object -- JoAnn Paules MVP Microsoft [Publisher] Tech Editor for "Microsoft Publisher 2007 For Dummies" "Likita Rucker" <Likita Rucker@discussions.microsoft.com> wrote in message news:3892AD59-4452-4199-BC8E-31AE4220B6A7@microsoft.com... >I need help inserting a document in Office 2007, please help. If you click Insert > Object and pick Object from the dropdown, you'll get only the first page of the insert because an "object" can't cross a page boun...

M2005 -- one word.... UGGGHHH!!!
I just got the demo... was using M04 small biz. Very disappointed. 1) Runs like a SLOTH in need of a NAP, on my 3.4GHz P4 / 1GB ram. 2) MSN crap littered in every nook and cranny possible. 3) Apparently uses IE engine to "render" all pages so everything has a clunky "web-browsery" feel to it. 4) No "Find" function?? How do I just "Find" a transaction across all accounts??? Hello????? 5) Money Express has gone by the wayside... apparently they want you to use MSN Alerts. Well, I don't have MSN Messenger installed on my machine because I...

Can't See Word Check Boxes in Outlook
I have a Word Document that I wish to send via the File->Send To->Mail Recipient once it is filled in. The document has questions that require the User to select a check box for the different selections (Excellent, Good, Poor, Very Poor). When I send the document, the check boxes show up in Outlook, however when the email arrives the check boxes are no longer there. Is there a way to have the check boxes show up in the email, or, are they somehow being stripped? ...

how do i print a smaller image of my saved document?
I forgot how to do this. My age is taking its toll! Don't blame age, as I don't think Word has any built-in way to do this unless you're thinking of the Zoom feature in the Print dialog, which allows you to print multiple pages per sheet. -- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA http://word.mvps.org "wallyb" <wallyb@discussions.microsoft.com> wrote in message news:8B90FC4B-6B36-4BF0-99C4-8A099673B6EE@microsoft.com... >I forgot how to do this. My age is taking its toll! > ...

How do I create a horizontal document in publisher?
I want to create a 6" high X 11" wide document in Publisher and do not know how. Anyone have the answer? Start a new document and set your page up with those dimensions. -- JoAnn Paules Microsoft MVP - Publisher How to ask a question http://support.microsoft.com/kb/555375 "chirostv55" <chirostv55@discussions.microsoft.com> wrote in message news:F04A96EC-5593-4781-AA3F-D63D0B5DE02E@microsoft.com... >I want to create a 6" high X 11" wide document in Publisher and do not know > how. Anyone have the answer? What version Publisher? If you ar...

Word as Editor in OL 2003
I'm trying to use Word as my html editor in OL 2003. I must have changed a setting and now the text I see is about 18 pt. Arial instead of the 10 pt. Arial I see if I use plain text. Is there a setting I can change? Thanks. Never mind. "hank" <not@home.com> wrote in message news:OlbM9zNvDHA.2072@TK2MSFTNGP10.phx.gbl... > I'm trying to use Word as my html editor in OL 2003. I must have changed a > setting and now the text I see is about 18 pt. Arial instead of the 10 pt. > Arial I see if I use plain text. Is there a setting I can change? Thanks. > > ...

Contatcs interfering with Word Mailmerge
Hi - I have been using MVP Doug Robbins' solution for sending attachments with email merges in Word (http://word.mvps.org/FAQs/MailMerge/MergeWithAttachments.htm) everything is fine EXCEPT that Outlook seems to be overriding the email addresses I specify in the Wred directory file and replacin with email addresses it 'thinks' fits the addressee best. I've no idea how irt is doing this. I have corresponded directly wit Doug in the Mailmerge Group - he had never seen this - suggested I try here. Any ideas!? -- Grapevine Not without any information. The followi...

how to only show first 20 words of a memo field
I have a memo field on a form, how can i show the first 30 characters and add 3 periods after the first 30 words. -- Message posted via AccessMonster.com http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200711/1 Use the Left function and add 3 periods: Left(string, length) & "..." "sheniece via AccessMonster.com" wrote: > I have a memo field on a form, how can i show the first 30 characters and > add 3 periods after the first 30 words. > > -- > Message posted via AccessMonster.com > http://www.accessmonster.com/Uwe/Forums...

VBA Help #4
Hi, I have a list of clients with their associated outstanding dollar amount and their return (%). I would like to know if there is code that would allow me to break up these clients by return (%) groupings. For example, I would like to group below 10%, 10% to 17%, and above 17%. So at the client on the list that is just before 10% I would like to add two rows and put a dollar subtotal in the immediate row and sum the dollar amounts. Can anyone help? Thanks, Marino Public Sub ProcessData() Const TEST_COLUMN As String = "A" '<=== change to suit Dim i As Long Dim LastR...

expanded comments on documents
I would like to have the ability to put lengthy transaction descriptions on documents and in GL transactions. Currently, description fields are limited in the GL. Additionally, notes/comments can be lengthy, but report fields for them are limited in the number of characters that appear on the reports. ---------------- This post is a suggestion for Microsoft, and Microsoft responds to the suggestions with the most votes. To vote for this suggestion, click the "I Agree" button in the message pane. If you do not see the button, follow this link to open the suggestion in the Mic...

you do not have credentials that allow you to open this document
When i open a existing .doc document.It shows message "like you do not have credentials that allow you to open this document.Do You want to open it using a different set of credentials? " i can't able to open any .doc document ...

How to dete items in 'Recent Document' window
When one clicks on the office button, a window pops up showing a long list of previous opened Excel files. I would like to delete those items that reference a CD drive. How do I do that? ed See the Ribbon Tips section on this page (Dictator examples) There is a workbook that you can download with a example to disable the list http://www.rondebruin.nl/ribbon.htm -- Regards Ron de Bruin http://www.rondebruin.nl/tips.htm "OldManEd" <econgleton@snet.net> wrote in message news:O%23LyAb5jIHA.5956@TK2MSFTNGP03.phx.gbl... > When one clicks on the office button, a window p...

Need A formula in VBA ,Similar to NETWORKDAYS in excel
I would like to get only working days after excluding satuday and sunda and holidays. Holidays will be there in the range of sheet There is one formula in xls (NETWORKDAYS) , It would be appreciated i you can make it similar one. The format of NETWORKDAYS is NETWORKDAYS(STARTDATE,ENDDATE,HOLIDAY-RANGE) Regards Joph -- Message posted from http://www.ExcelForum.com On Mon, 12 Jan 2004 22:03:12 -0600, jophy <<jophy.zycba@excelforum-nospam.com>> wrote: >I would like to get only working days after excluding satuday and sunday >and holidays. Holidays will be there in the rang...

Export Data to MS Word Table and Format
Hello Everyone, I've gathered code from other posts and have come up with output to a Word document that is acceptable (thanks to everyone for sharing). I would like know if it is possible to format the table in MS Word. 1) Left justifying the 1st column, and centering the data in columns 2 to 4. 2) Is there a better way of handling the column widths to automatically size to the widest data in the column. 3) Any good resources to help export data to MS Word. Here's what I have so far... Sub Export_Word() Dim oWord As Word.Application Dim oDoc As Word.Documen...

Send the Document, may differ some place due to cell contents...
I think subject wasn't so good that tell you what i wanted to do... I have a text that is about an a4 page in Word. I have an Database of about 150 firms. And two colums; Company name & Company Productivety. Company name Producktivety a 90 b 50 ... .. ... .. And so goes. And the text is like; -------------------------- .................................................. ............ .. ......... Company name: a Company productivety: 90 -...

Converting Excel with Word
Hi to everyone. I have a table in an Excel sheet. In every row of the table included some information’s of a number of persons (Name, address, age, work hours, distance, etc) I also have a doc file in Word, which i use it like a form, to connect the above information’s in some points in the doc. I would like to convert somehow the Excel table to word doc applying 2 conditions. a) Every time that i change a value of a person at the Excel table, automatically updating the corresponding doc file and b) If i must add new persons in the table (that means new rows), also to create automatical...