i had tried with my code but it not copy as each 2 segment into one page all range copy in one page i want each 2rows date in one page
i want set location path on code to save word on particular path file
help me on this
pls find the error attachmentSub run() Dim wdDoc As Word.document, wdTbl As Word.Table, wdApp As Object, wdRng As Word.Range Dim iRow As Integer, aSheet As Worksheet, iCol As Integer, iPair As Integer Dim sPath As String Set aSheet = ActiveSheet iRow = 2 sPath = ActiveWorkbook.Path & "\" Set wdApp = CreateObject("Word.Application") wdApp.Visible = True Set wdDoc = wdApp.Documents.Add(sPath & "OUTPUT_RESULT-FILE.docx") Do While aSheet.Cells(iRow, 1).Value <> "" Set wdRng = wdDoc.Range wdRng.Collapse Direction:=0 wdRng.InsertBefore Chr(13) & Chr(13) wdRng.Collapse Direction:=0 wdRng.FormattedText = wdDoc.Tables(1).Range.FormattedText Set wdTbl = wdRng.Tables(1) For iPair = 0 To 1 For iCol = 0 To 7 wdTbl.Cell(iCol + 1, iPair + 2).Range.Text = aSheet.Cells(iRow, 1).Offset(iPair, iCol).Value Next iCol Next iPair iRow = iRow + 2 Loop End Sub
thanks




Reply With Quote
