PDA

View Full Version : macro to save "word document", name using two cells in the table



shadyhoo
12-09-2017, 08:51 AM
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

21130

file path

21131

in attachment samples of file

macropod
12-09-2017, 01:35 PM
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