![]() |
|
|
|
#1
|
||||
|
||||
|
Hi Dan,
Whos's Kevin? The issue with the AutoOpen macro is that it won't run as a Private sub. Delete 'Private' and it should run. However, if the document is protected, as you say it is, you'll get a run time error. The document needs to be unprotected before you can change the design mode. Try as I might, though, I can't get Word to protect a document and leave it in design mode. So developing & testing code to get a protected document out of design mode is somewhat problematic ... Give the following a go. It'll work with a protected document and explcity turns off design mode. Code:
Sub AutoOpen()
' Runs when this document is opened.
Dim Pwd As String ' String variable to hold passwords for protected documents
Dim pState As Boolean ' Document protection state flag
With ActiveDocument
' Insert your document's password between the double quotes on the next line
Pwd = ""
' Initialise the protection state
pState = False
' If the document is protected, unprotect it
If .ProtectionType <> wdNoProtection Then
' Update the protection state
pState = True
' Unprotect the document
.Unprotect Pwd
End If
' Swith off Design Mode
.FormsDesign = False
' If the document was protected, reprotect it, preserving any formfield contents
If pState = True Then .Protect wdAllowOnlyFormFields, Noreset:=True, Password:=Pwd
End With
End Sub
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
|
#2
|
|||
|
|||
|
The email messages that are sent to me indicating that there has been a posting to this thread come from Kevin@msofficeforums.com, so I jumped to the wrong conclusion.
I inserted the latest code you provided in place of the previous code. An error message came up telling me that macros were disabled and that I should enable them. I tried to use Word's help function to learn how to do that, but I was unsuccessful. So I have attached the latest version of the Word 2000 file that represents the form I have been trying to create so that you can see if I have done something wrong. I am not at all sure that I have but your code in the write place, but I'm not sure where else to put it. Thanks, again, for your help. Dan |
|
| Tags |
| design mode, protected form |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Adding table lines to protected form | razberri | Word Tables | 2 | 10-27-2010 05:58 PM |
| Font size changes in a protected form..? | jackbkmp | Word VBA | 0 | 03-03-2010 10:14 AM |
| Editing Password protected form fields in Word 2007 | tamilan | Word | 2 | 02-16-2010 09:45 AM |
| Form design question | aalytics | Word | 0 | 12-04-2009 07:32 PM |
| protected form with underline fillable spaces | rohitsahib | Word | 0 | 02-02-2006 10:22 AM |