B
Big Al
I have created a form with a macro. The macro cuts and pastes some of the
fields when the user needs to add extra data e.g. another person name. The
macro unprotects the document copies and pastes then re-protects. However if
the user enters the details in the form in the first section, runs the macro
to add extra fields, it clears all the existing data from the fields. How do
I stop that?
The code I wrote is:
Sub AddEmployee()
'
' AddEmployee Macro
' Macro recorded 26/11/2007 by MATHISOA
' If document is protected, Unprotect it.
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If
Selection.MoveUp Unit:=wdLine, Count:=4, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.PasteAndFormat (wdPasteDefault)
'ReProtect the document.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect wdAllowOnlyFormFields
End If
End Sub
fields when the user needs to add extra data e.g. another person name. The
macro unprotects the document copies and pastes then re-protects. However if
the user enters the details in the form in the first section, runs the macro
to add extra fields, it clears all the existing data from the fields. How do
I stop that?
The code I wrote is:
Sub AddEmployee()
'
' AddEmployee Macro
' Macro recorded 26/11/2007 by MATHISOA
' If document is protected, Unprotect it.
If ActiveDocument.ProtectionType <> wdNoProtection Then
ActiveDocument.Unprotect Password:=""
End If
Selection.MoveUp Unit:=wdLine, Count:=4, Extend:=wdExtend
Selection.Copy
Selection.MoveDown Unit:=wdLine, Count:=4
Selection.PasteAndFormat (wdPasteDefault)
'ReProtect the document.
If ActiveDocument.ProtectionType = wdNoProtection Then
ActiveDocument.Protect wdAllowOnlyFormFields
End If
End Sub