Welcome. I have this code to create and copy data to a Word file and it works fine for me. Except for the date format in column C, it is copied as follows:
dd/mm/yyyy
What I'm looking for is how to change the date format after copying to yyyy/mm/dd
I tried changing it in the master data, but to no avail
dd/mm/yyyy
What I'm looking for is how to change the date format after copying to yyyy/mm/dd
I tried changing it in the master data, but to no avail
VBA Code:
Sub ExcelToWordSheet1()
Dim lr As Long
Dim WS As Worksheet: Set WS = Sheets("Sheet1")
On Error Resume Next
Dim docDest As Word.Document
Dim src As Word.Application
Set src = CreateObject("word.application")
src.Visible = True
xname = "Word"
XPath = ThisWorkbook.path & "\" & xname
Application.ScreenUpdating = False
lr = WS.Cells(WS.Rows.Count, "A").End(xlUp).Row
WS.Range("A7: k" & lr).Copy
Set docDest = src.Documents.Add
src.Selection.PasteExcelTable _
LinkedToExcel:=False, WordFormatting:=False, RTF:=False
Application.CutCopyMode = False
src.ActiveDocument. _
PageSetup.Orientation = wdOrientLandscape
src.ActiveDocument. _
PageSetup.PaperSize = WdPaperSize.wdPaperA3
If Dir(XPath, vbDirectory) = "" Then MkDir XPath
docDest.SaveAs XPath & "\" & WS.Name & ".docx"
docDest.Close
Set docDest = Nothing
src.Quit
Set src = Nothing
Application.ScreenUpdating = True
MsgBox "Done", vbInformation
End Sub