+ Reply to Thread
Results 1 to 2 of 2

Thread: How to have Word 2007 Doc to SAVE AS text according to form field.

  1. #1
    Forum Contributor
    Join Date
    12-27-2007
    Posts
    104

    Question How to have Word 2007 Doc to SAVE AS text according to form field.

    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?

  2. #2
    Forum Contributor
    Join Date
    12-27-2007
    Posts
    104

    Re: How to have Word 2007 Doc to SAVE AS text according to form field.

    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

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0