Consulting

Results 1 to 2 of 2

Thread: macro to save "word document", name using two cells in the table

  1. #1
    VBAX Newbie
    Joined
    Dec 2017
    Posts
    2
    Location

    macro to save "word document" name using two cells in the table

    please i want "macro word" to save file using number and word from the table".
    the number and the word change on every new document " for example i want file name to be " 1739 lifting" and next document is "1740 hot" next"1741 lifting" next "1742 hot" next "1743 confined " .


    the cell of permit name & cell of permit number, i type it manually every document "not fixed".


    i want macro takes "number" and "word" from table and save it by number and permit type ( 1739 lifting or 1790 hot or 1780 confined or .....) . takes it from cells in the first row.


    macro to save "word document", name using two cells in the table

    2.jpg

    file path

    1.jpg

    in attachment samples of file
    Attached Files Attached Files
    Last edited by shadyhoo; 12-09-2017 at 11:37 AM.

  2. #2
    Knowledge Base Approver VBAX Guru macropod's Avatar
    Joined
    Jul 2008
    Posts
    4,435
    Location
    For whatever reason, your attachments are in different file formats. To save the document in the docx format you might try something along the lines of:
    Sub Demo()
        Dim StrFlNm As String
        With ActiveDocument
            StrFlNm = Split(.Tables(1).Cell(1, 5).Range.Text, vbCr)(0) & " " & Split(.Tables(1).Cell(1, 2).Range.Text, vbCr)(0)
            StrFlNm = "C:\Users\" & Environ("Username") & "\Documents\" & StrFlNm
            .SaveAs FileName:=StrFlNm & ".docx", FileFormat:=wdFormatXMLDocument, AddToRecentFiles:=False
        End With
    End Sub
    Last edited by macropod; 12-10-2017 at 12:49 PM.
    Cheers
    Paul Edstein
    [Fmr MS MVP - Word]

Posting Permissions

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