Hi
I've designed a form in word - working well.
I would like to add a button at the end of the form, which when pressed by user will save the document in a file-name according to text in 2 of the fields.
Field 1: Surname - this is constructed in the form by using the legacy tools, text.
Field 2: Date of Birth - this is constructed in the form by using the legacy tools, text.
So the button at the bottom, once form filled by user, will save the document as:
Surname Date of Birth.docx
i.e. If Field 1 = Smith, Field 2 = 10/10/67 - file to be saved as smith101067
Is this possible?
Ok
I've managed to find:
http://www.eggheadcafe.com/community...bookmarks.aspx
and have managed to resolve the initial issue that I posted.
What I have now - is that my Date of Birth field is formatted as ##/##/## - but the file-name cannot have " / "
I want to have " / " displayed on the form, but how do I just extract the numbers and not the " / " for the save as file name function??
My Code:
Private Sub CommandButton1_Click()
Dim pStr As String
pStr = "C:\Users\Tony\Desktop\" 'Your directory
pStr = pStr + ActiveDocument.Bookmarks("SurName").Range.Text
pStr = pStr + " "
pStr = pStr + ActiveDocument.Bookmarks("DOB").Range.Text
pStr = pStr + " .doc"
ActiveDocument.SaveAs FileName:=pStr
Dim sCode As String
MsgBox "Your file is now saved, it is now safe to close the document"
End Sub
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks