Maybe try the following
Sub CopyExcelDataToWord() ' Declare variables Dim xlApp As Excel.Application Dim xlWB As Excel.Workbook Dim xlSheet As Excel.Worksheet Dim rng As Excel.Range Dim wdApp As Word.Application Dim wdDoc As Word.Document Dim wdRng As Word.Range ' Create Excel Application object Set xlApp = New Excel.Application xlApp.Visible = False ' Hide Excel application ' Open the Excel workbook Set xlWB = xlApp.Workbooks.Open("C:\Path\To\Your\Excel\File.xlsx") ' Replace with the actual path to your Excel file ' Select the worksheet and range Set xlSheet = xlWB.Sheets("Sheet1") ' Replace "Sheet1" with the actual sheet name Set rng = xlSheet.Range("A1:B10") ' Replace with the actual range ' Create Word Application object Set wdApp = New Word.Application wdApp.Visible = True ' Show Word application ' Open or create the Word document Set wdDoc = wdApp.Documents.Open("C:\Path\To\Your\Word\Document.docx") ' Replace with the actual path to your Word document ' If the document doesn't exist, it will be created ' Find the specific paragraph Set wdRng = wdDoc.Paragraphs(1).Range ' Replace 1 with the paragraph number ' Paste Excel data into Word wdRng.PasteSpecial DataType:=wdPasteExcelTable ' Close and quit Excel xlWB.Close False xlApp.Quit ' Save and close Word wdDoc.Save wdDoc.Close ' Quit Word wdApp.Quit ' Clean up objects Set rng = Nothing Set xlSheet = Nothing Set xlWB = Nothing Set xlApp = Nothing Set wdRng = Nothing Set wdDoc = Nothing Set wdApp = Nothing End Sub




Reply With Quote