bryVA
08-07-2009, 10:13 AM
Hello,
I am trying to get a word document that is protected to take the information placed in a Drop Down form field and use that as part of the name when saving the document. I have the following code:
Sub Save_File()
Dim Today, FolderName$, DateValue$, NameofFile$, FullFileName$, NCC
Set aDoc = ActiveDocument
If aDoc.ProtectionType <> wdNoProtection Then
aDoc.Unprotect
NCC = ActiveDocument.Bookmarks("Dropdown1").Range.Text
aDoc.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End If
FolderName$ = ActiveDocument.Path & "\"
DateValue$ = Format(Now, "yy-mm-dd hhmmss")
NameofFile$ = NCC
FullFileName$ = FolderName$ + NameofFile$ + " " + DateValue$
aDoc.SaveAs FullFileName$, _
FileFormat:=wdFormatDocument, LockComments:=False, _
Password:="", AddToRecentFiles:=True, WritePassword:="", _
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub
This doesn't work because its not as it is not extracting the text from the drop down.
I also want to after saving the file to automatically print the file and then clear all the form fields. How would I do that?
I have attached a copy of what I am trying to do.
Thanks all,
-B
I am trying to get a word document that is protected to take the information placed in a Drop Down form field and use that as part of the name when saving the document. I have the following code:
Sub Save_File()
Dim Today, FolderName$, DateValue$, NameofFile$, FullFileName$, NCC
Set aDoc = ActiveDocument
If aDoc.ProtectionType <> wdNoProtection Then
aDoc.Unprotect
NCC = ActiveDocument.Bookmarks("Dropdown1").Range.Text
aDoc.Protect Type:=wdAllowOnlyFormFields, _
NoReset:=True
End If
FolderName$ = ActiveDocument.Path & "\"
DateValue$ = Format(Now, "yy-mm-dd hhmmss")
NameofFile$ = NCC
FullFileName$ = FolderName$ + NameofFile$ + " " + DateValue$
aDoc.SaveAs FullFileName$, _
FileFormat:=wdFormatDocument, LockComments:=False, _
Password:="", AddToRecentFiles:=True, WritePassword:="", _
ReadOnlyRecommended:=False, EmbedTrueTypeFonts:=False, _
SaveNativePictureFormat:=False, SaveFormsData:=False, _
SaveAsAOCELetter:=False
End Sub
This doesn't work because its not as it is not extracting the text from the drop down.
I also want to after saving the file to automatically print the file and then clear all the form fields. How would I do that?
I have attached a copy of what I am trying to do.
Thanks all,
-B