A
Autobahn
I am creating a form that will be sent out with people who have laptops
but no connection to a centralized server. They will be creating many unique
documents from the standard forms and we are standardizing the name of the
resulting .doc files to be created from three fields on the form. LastName,
Firstame, Date. The Lastname and FirstName fields are input while the date
is an autogenerated field. I want to add a button to the field that will
save the document automatically with the proper file naming convention. Here
is the code I am currently using, but I know part of it is wrong and I have
no idea how to grab the information out of an autogenerated field:
XXXXXXXX
Sub Save()
Dim objWord As Word.Application
'Note: I know this next line is wrong, what should I set this to?
Set objWord = CurrentApplication
With objWord
..Visible = True
'Move to each bookmark and insert text from the form.
..ActiveDocument.Bookmarks("Text1").Select
..Selection.Text = (CStr(Forms!MainData!FirstName))
..ActiveDocument.Bookmarks("Text2").Select
..Selection.Text = (CStr(Forms!MainData!LastName))
End With
'Note: I did not try to input the date field, any help would be great.
Dim FName As String
FName = Forms!MainData!FirstName & " " & Forms!MainData!LastName & ".doc"
objWord.ActiveDocument.SaveAs FileName:=FName
End Sub
XXXXXX
but no connection to a centralized server. They will be creating many unique
documents from the standard forms and we are standardizing the name of the
resulting .doc files to be created from three fields on the form. LastName,
Firstame, Date. The Lastname and FirstName fields are input while the date
is an autogenerated field. I want to add a button to the field that will
save the document automatically with the proper file naming convention. Here
is the code I am currently using, but I know part of it is wrong and I have
no idea how to grab the information out of an autogenerated field:
XXXXXXXX
Sub Save()
Dim objWord As Word.Application
'Note: I know this next line is wrong, what should I set this to?
Set objWord = CurrentApplication
With objWord
..Visible = True
'Move to each bookmark and insert text from the form.
..ActiveDocument.Bookmarks("Text1").Select
..Selection.Text = (CStr(Forms!MainData!FirstName))
..ActiveDocument.Bookmarks("Text2").Select
..Selection.Text = (CStr(Forms!MainData!LastName))
End With
'Note: I did not try to input the date field, any help would be great.
Dim FName As String
FName = Forms!MainData!FirstName & " " & Forms!MainData!LastName & ".doc"
objWord.ActiveDocument.SaveAs FileName:=FName
End Sub
XXXXXX