S
SteveV
Problem 1: ActiveDocument.AttachedTemplate =
sMyNewFullyQualifiedTemplatePath
results in the following error:
Run-time error '5598'
Word cannot attach a document to a protected template
Problem 2: There appears to be no way to unprotect a template, which
in the case a doc template with many, many form fields. Leaving the
template unprotected is not an option as I need to prevent users from
messing with the form fields and document layout and I need to have
the form fields function as, um well, form fields.
Here is my code:
Set curTemplate = ActiveDocument.AttachedTemplate
Dim sCurTemplatePath As String
sCurTemplatePath = curTemplate.Path & Application.PathSeparator &
curTemplate.Name
If StrComp(sCurTemplatePath, sTargetTemplatePath, vbTextCompare) <> 0
Then
UnprotectForm
ActiveDocument.AttachedTemplate = sTargetTemplatePath
ProtectForm
Dim sMsg As String
sMsg = "Fixed incorrect Clinic Note Template location." & vbCrLf &
vbCrLf & "Old: " _
& sCurTemplatePath & vbCrLf & vbCrLf & "New: " &
sTargetTemplatePath
MsgBox sMsg, vbInformation + vbOKOnly, "Relinking Clinic Note
Template"
End If
Does anyone have any insight as to how it might get this to work?
Thanks in advance!
--Steve
sMyNewFullyQualifiedTemplatePath
results in the following error:
Run-time error '5598'
Word cannot attach a document to a protected template
Problem 2: There appears to be no way to unprotect a template, which
in the case a doc template with many, many form fields. Leaving the
template unprotected is not an option as I need to prevent users from
messing with the form fields and document layout and I need to have
the form fields function as, um well, form fields.
Here is my code:
Set curTemplate = ActiveDocument.AttachedTemplate
Dim sCurTemplatePath As String
sCurTemplatePath = curTemplate.Path & Application.PathSeparator &
curTemplate.Name
If StrComp(sCurTemplatePath, sTargetTemplatePath, vbTextCompare) <> 0
Then
UnprotectForm
ActiveDocument.AttachedTemplate = sTargetTemplatePath
ProtectForm
Dim sMsg As String
sMsg = "Fixed incorrect Clinic Note Template location." & vbCrLf &
vbCrLf & "Old: " _
& sCurTemplatePath & vbCrLf & vbCrLf & "New: " &
sTargetTemplatePath
MsgBox sMsg, vbInformation + vbOKOnly, "Relinking Clinic Note
Template"
End If
Does anyone have any insight as to how it might get this to work?
Thanks in advance!
--Steve