Info

Bookmarks can also be used as markers for bringing in Charts created in Excel (see Figure 16.11). The following links an Excel chart to the memo:

Sub CreateMemo()

Dim myArray()

Dim wdBkmk As String

Dim wdApp As Word.Application Dim wdRng As Word.Range myArray = Array("To", "CC", "From", "Subject", "Chart") Set wdApp = GetObject(, "Word.Application")

Set wdRng = wdApp.ActiveDocument.Bookmarks(myArray(0)).Range wdRng.InsertBefore ("Bill Jelen")

Set wdRng = wdApp.ActiveDocument.Bookmarks(myArray(1)).Range wdRng.InsertBefore ("Tracy Syrstad")

Set wdRng = wdApp.ActiveDocument.Bookmarks(myArray(2)).Range wdRng.InsertBefore ("MrExcel")

Set wdRng = wdApp.ActiveDocument.Bookmarks(myArray(3)).Range wdRng.InsertBefore ("Fruit & Vegetable Sales")

Set wdRng = wdApp.ActiveDocument.Bookmarks(myArray(4)).Range

ActiveSheet.ChartObjects("Chart 1").Copy wdRng.Select wdRng.Application.Selection.PasteAndFormat Type:=2 wdApp.Activate

Set wdApp = Nothing Set wdRng = Nothing End Sub

0 0

Post a comment