DrChrisB
01-14-2011, 06:12 PM
I am having a problem using VBA in MS Word. For some reason my simple code works when I open a file but does not work if the file is a hyperlink on our company intranet.
I have a form called Request.doc with a field that it todays date using the format yymmddhhmm. Every time the file opens the number changes. I want the number to lock when a user closes the file at the same time he/she renames the file.
My code is below. Again the code executes if I open Request.doc, but it does not work if Request.doc is a hyperlink on our company intranet.
Sub Document_Close()
If ActiveDocument.Name <> Request.doc" Then
ActiveDocument.Unprotect Password:="Siltronic"
ActiveDocument.Fields.Locked = True
ActiveDocument.Protect Password:="Siltronic", NoReset:=False, Type:= _
wdAllowOnlyRevisions
ActiveDocument.Fields.Unlink
End If
End Sub
Can someone please explain why and offer a solution?
I have a form called Request.doc with a field that it todays date using the format yymmddhhmm. Every time the file opens the number changes. I want the number to lock when a user closes the file at the same time he/she renames the file.
My code is below. Again the code executes if I open Request.doc, but it does not work if Request.doc is a hyperlink on our company intranet.
Sub Document_Close()
If ActiveDocument.Name <> Request.doc" Then
ActiveDocument.Unprotect Password:="Siltronic"
ActiveDocument.Fields.Locked = True
ActiveDocument.Protect Password:="Siltronic", NoReset:=False, Type:= _
wdAllowOnlyRevisions
ActiveDocument.Fields.Unlink
End If
End Sub
Can someone please explain why and offer a solution?