M
mr tom
I'm automating a pile of stuff in word 97 using VBA.
I have created a form which many staff complete and email back to me
(filename will of course vary).
I've protected it (inc password) to ensure it is correctly completed.
To ensure it travels safely through our corporate firewalls, no VB Code in
it (so can't standardise save name).
So - the problem:
I have a control file which operates on it and have VBA code which seems to
work (it will detect it as the only other active document, which will do for
now)
The control file does it's job fine once the form is unprotected, but
doesn't want to once the protection is in place.
I've tried various iterations of the unprotect command, as you'll see from
the sample code I've attached below.
I'd love to hear any suggestions you may have.
Many thanks in advance,
Tom.
Sub SaveReconForm()
' Switch to the recon form
' ActiveWindow.Next.Activate
' Unprotect the recon form
ActiveWindow.Next.Unprotect Password:="xyz"
ActiveWindow.Next.Activate
Documents (Next).Unprotect Password:="xyz"
' ActiveDocument.Unprotect Password:="xyz"
' Refer to scheme name and scheme number bookmarks and make them strings
Dim strSchemename As String
strSchemename = ActiveDocument.FormFields("SchemeName").Range.Text
Dim strSCN As String
strSCN = ActiveDocument.FormFields("SCN").Range.Text
' Save the recon form in j:\reconforms\RF - Schemename - SCN.doc
ActiveDocument.SaveAs FileName:="j:\reconstructions\Recon Forms\RF - " &
strSchemename & " - " & strSCN & ".doc"
End Sub
I have created a form which many staff complete and email back to me
(filename will of course vary).
I've protected it (inc password) to ensure it is correctly completed.
To ensure it travels safely through our corporate firewalls, no VB Code in
it (so can't standardise save name).
So - the problem:
I have a control file which operates on it and have VBA code which seems to
work (it will detect it as the only other active document, which will do for
now)
The control file does it's job fine once the form is unprotected, but
doesn't want to once the protection is in place.
I've tried various iterations of the unprotect command, as you'll see from
the sample code I've attached below.
I'd love to hear any suggestions you may have.
Many thanks in advance,
Tom.
Sub SaveReconForm()
' Switch to the recon form
' ActiveWindow.Next.Activate
' Unprotect the recon form
ActiveWindow.Next.Unprotect Password:="xyz"
ActiveWindow.Next.Activate
Documents (Next).Unprotect Password:="xyz"
' ActiveDocument.Unprotect Password:="xyz"
' Refer to scheme name and scheme number bookmarks and make them strings
Dim strSchemename As String
strSchemename = ActiveDocument.FormFields("SchemeName").Range.Text
Dim strSCN As String
strSCN = ActiveDocument.FormFields("SCN").Range.Text
' Save the recon form in j:\reconforms\RF - Schemename - SCN.doc
ActiveDocument.SaveAs FileName:="j:\reconstructions\Recon Forms\RF - " &
strSchemename & " - " & strSCN & ".doc"
End Sub