Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 12-29-2010, 02:10 PM
macropod's Avatar
macropod macropod is offline Form protected in design mode-can't do anything Windows 7 32bit Form protected in design mode-can't do anything Office 2000
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 22,523
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

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
The code can be run manually or by opening the document.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
 

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

Other Forums: Access Forums

All times are GMT -7. The time now is 01:37 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft