Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
WordWorker WordWorker is offline
external usenet poster
 
Posts: 16
Default Macro to Unlock a Locked Word 2007 Document

Is it possible -- and how do I do it -- to write a macro that a text input
field will run to temporarily unlock a locked Word 2007 form? I wrote one
that will lock the document that will run "On exit" from a field, but no
matter how I phrase it I can't get a macro to unlock the doc.

  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Macro to Unlock a Locked Word 2007 Document

Sub OnExit()
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
MsgBox "I'm unlocked. Do your deed."
ActiveDocument.Protect wdAllowOnlyFormFields, True
MsgBox "I'm back in chains."
Else
MsgBox "I wasn't locked to start with"
End If
End Sub



WordWorker wrote:
Is it possible -- and how do I do it -- to write a macro that a text
input field will run to temporarily unlock a locked Word 2007 form?
I wrote one that will lock the document that will run "On exit" from
a field, but no matter how I phrase it I can't get a macro to unlock
the doc.


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org



  #3   Report Post  
Posted to microsoft.public.word.docmanagement
WordWorker WordWorker is offline
external usenet poster
 
Posts: 16
Default Macro to Unlock a Locked Word 2007 Document

Thank you so much, Greg. You are a job saver!


"Greg Maxey" wrote:

Sub OnExit()
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
MsgBox "I'm unlocked. Do your deed."
ActiveDocument.Protect wdAllowOnlyFormFields, True
MsgBox "I'm back in chains."
Else
MsgBox "I wasn't locked to start with"
End If
End Sub



WordWorker wrote:
Is it possible -- and how do I do it -- to write a macro that a text
input field will run to temporarily unlock a locked Word 2007 form?
I wrote one that will lock the document that will run "On exit" from
a field, but no matter how I phrase it I can't get a macro to unlock
the doc.


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org




  #4   Report Post  
Posted to microsoft.public.word.docmanagement
WordWorker WordWorker is offline
external usenet poster
 
Posts: 16
Default Macro to Unlock a Locked Word 2007 Document

My excitement jumped the gun. I forgot to mention that the document is
password protected. As such, when it gets to the "ActiveDocument.Unprotect"
line, it chokes. I tried putting in the password as the string is indicated
to be written (see below), but the Debugger doesn't like that either. What
am I missing? What am I doing wrong?

ActiveDocument.Unprotect(password)


"Greg Maxey" wrote:

Sub OnExit()
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
MsgBox "I'm unlocked. Do your deed."
ActiveDocument.Protect wdAllowOnlyFormFields, True
MsgBox "I'm back in chains."
Else
MsgBox "I wasn't locked to start with"
End If
End Sub



WordWorker wrote:
Is it possible -- and how do I do it -- to write a macro that a text
input field will run to temporarily unlock a locked Word 2007 form?
I wrote one that will lock the document that will run "On exit" from
a field, but no matter how I phrase it I can't get a macro to unlock
the doc.


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org




  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Greg Maxey[_2_] Greg Maxey[_2_] is offline
external usenet poster
 
Posts: 668
Default Macro to Unlock a Locked Word 2007 Document

Replace "password" with the real password:

Sub OnExit()
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect Password:="password"
MsgBox "I'm unlocked. Do your deed."
ActiveDocument.Protect wdAllowOnlyFormFields, True
MsgBox "I'm back in chains."
Else
MsgBox "I wasn't locked to start with"
End If
End Sub


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org


"WordWorker" wrote in message
...
My excitement jumped the gun. I forgot to mention that the document is
password protected. As such, when it gets to the
"ActiveDocument.Unprotect"
line, it chokes. I tried putting in the password as the string is
indicated
to be written (see below), but the Debugger doesn't like that either.
What
am I missing? What am I doing wrong?

ActiveDocument.Unprotect(password)


"Greg Maxey" wrote:

Sub OnExit()
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
MsgBox "I'm unlocked. Do your deed."
ActiveDocument.Protect wdAllowOnlyFormFields, True
MsgBox "I'm back in chains."
Else
MsgBox "I wasn't locked to start with"
End If
End Sub



WordWorker wrote:
Is it possible -- and how do I do it -- to write a macro that a text
input field will run to temporarily unlock a locked Word 2007 form?
I wrote one that will lock the document that will run "On exit" from
a field, but no matter how I phrase it I can't get a macro to unlock
the doc.


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org








  #6   Report Post  
Posted to microsoft.public.word.docmanagement
WordWorker WordWorker is offline
external usenet poster
 
Posts: 16
Default Macro to Unlock a Locked Word 2007 Document

Thank you. It was the colon I had wrong. I was using a semicolon.

"Greg Maxey" wrote:

Replace "password" with the real password:

Sub OnExit()
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect Password:="password"
MsgBox "I'm unlocked. Do your deed."
ActiveDocument.Protect wdAllowOnlyFormFields, True
MsgBox "I'm back in chains."
Else
MsgBox "I wasn't locked to start with"
End If
End Sub


--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org


"WordWorker" wrote in message
...
My excitement jumped the gun. I forgot to mention that the document is
password protected. As such, when it gets to the
"ActiveDocument.Unprotect"
line, it chokes. I tried putting in the password as the string is
indicated
to be written (see below), but the Debugger doesn't like that either.
What
am I missing? What am I doing wrong?

ActiveDocument.Unprotect(password)


"Greg Maxey" wrote:

Sub OnExit()
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
MsgBox "I'm unlocked. Do your deed."
ActiveDocument.Protect wdAllowOnlyFormFields, True
MsgBox "I'm back in chains."
Else
MsgBox "I wasn't locked to start with"
End If
End Sub



WordWorker wrote:
Is it possible -- and how do I do it -- to write a macro that a text
input field will run to temporarily unlock a locked Word 2007 form?
I wrote one that will lock the document that will run "On exit" from
a field, but no matter how I phrase it I can't get a macro to unlock
the doc.

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org







  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Graham Mayor Graham Mayor is offline
external usenet poster
 
Posts: 19,312
Default Macro to Unlock a Locked Word 2007 Document

You would need to re-apply the password when reprotecting:

Dim sPassword as string
sPassword = "password"

'Unprotect the file
If ActiveDocument.ProtectionType wdNoProtection Then
bProtected = True
ActiveDocument.Unprotect Password:=sPassword
End If

'Do your stuff then

'Reprotect the document.
If bProtected = True Then
ActiveDocument.Protect _
Type:=wdAllowOnlyFormFields, _
NoReset:=True, _
Password:=sPassword
End If


--

Graham Mayor - Word MVP

My web site www.gmayor.com
Word MVP web site http://word.mvps.org



Greg Maxey wrote:
Replace "password" with the real password:

Sub OnExit()
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect Password:="password"
MsgBox "I'm unlocked. Do your deed."
ActiveDocument.Protect wdAllowOnlyFormFields, True
MsgBox "I'm back in chains."
Else
MsgBox "I wasn't locked to start with"
End If
End Sub



"WordWorker" wrote in message
...
My excitement jumped the gun. I forgot to mention that the document
is password protected. As such, when it gets to the
"ActiveDocument.Unprotect"
line, it chokes. I tried putting in the password as the string is
indicated
to be written (see below), but the Debugger doesn't like that either.
What
am I missing? What am I doing wrong?

ActiveDocument.Unprotect(password)


"Greg Maxey" wrote:

Sub OnExit()
If ActiveDocument.ProtectionType wdNoProtection Then
ActiveDocument.Unprotect
MsgBox "I'm unlocked. Do your deed."
ActiveDocument.Protect wdAllowOnlyFormFields, True
MsgBox "I'm back in chains."
Else
MsgBox "I wasn't locked to start with"
End If
End Sub



WordWorker wrote:
Is it possible -- and how do I do it -- to write a macro that a
text input field will run to temporarily unlock a locked Word 2007
form? I wrote one that will lock the document that will run "On
exit" from a field, but no matter how I phrase it I can't get a
macro to unlock the doc.

--
Greg Maxey - Word MVP

My web site http://gregmaxey.mvps.org
Word MVP web site http://word.mvps.org



  #8   Report Post  
Maggiechen Maggiechen is offline
Banned
 
Posts: 0
Default

There could be 2 things that are wrong.

1) You have reached the end of the Microsoft Office 2007 Trial.
When this happens you are not able to edit any documents. You will only be able to view and print your documents.
To fix this you need to buy an office 2007 license from http://office.microsoft.com

2) You are trying to edit a protected document.
Some people protect their documents or parts of their documents from being edited. The only way around this is to get an original copy of the file or the password for the file.try to recover the word password with word password recovery 5.0, which is considered as the best word password recovery tool on the market.

Hope this helps you!
Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I am using forms in word 2007. I locked the file & need to unlock Unlock Word 2007 document & make changes Microsoft Word Help 1 September 11th 07 07:36 PM
Word document locked won't unlock Jeff Microsoft Word Help 1 February 19th 06 12:13 AM
How to unlock a document that Word locked by shutting down on its Frank Vivelo Microsoft Word Help 1 July 7th 05 09:35 PM
How do I unlock a document in word that is locked for edit? cricket Microsoft Word Help 0 March 2nd 05 05:47 PM
How do I unlock a word document that is "locked for edit"? Louise Microsoft Word Help 4 January 14th 05 08:37 PM


All times are GMT +1. The time now is 06:20 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"