How much do you love me?
Check this out.
Make sure to set a reference to MS Word Object Library.
Option Explicit Private Sub ExportToWord() Dim appWrd As Object Dim objDoc As Object Dim FilePath As String Dim FileName As String Dim x As Long Dim LastRow As Long Dim SheetChart As String Dim SheetRange As String Dim BookMarkChart As String Dim BookMarkRange As String FilePath = ThisWorkbook.Path FileName = "WorkWithExcel.doc" LastRow = Sheets("Summary").Range("A65536").End(xlUp).Row Set appWrd = CreateObject("Word.Application") appWrd.Visible = True On Error Resume Next Set objDoc = appWrd.Documents.Open(FilePath & "\" & FileName) On Error GoTo 0 If objDoc Is Nothing Then MsgBox "Unable to find the Word file.", vbCritical, "File Not Found" appWrd.Quit Set appWrd = Nothing Exit Sub End If For x = 2 To LastRow SheetChart = ThisWorkbook.Sheets("Summary").Range("A" & x).Text SheetRange = ThisWorkbook.Sheets("Summary").Range("B" & x).Text BookMarkChart = ThisWorkbook.Sheets("Summary").Range("C" & x).Text BookMarkRange = ThisWorkbook.Sheets("Summary").Range("D" & x).Text appWrd.Selection.Goto What:=wdGoToBookmark, Name:=BookMarkRange ThisWorkbook.Sheets(SheetRange).UsedRange.Copy appWrd.Selection.Paste appWrd.Selection.Goto What:=wdGoToBookmark, Name:=BookMarkChart ThisWorkbook.Sheets(SheetChart).ChartObjects(1).Copy appWrd.Selection.Paste Next End Sub





Reply With Quote