Hi,
I have an excel sheet and I'm searching for a keyword. From that keyword, I can find the data nearby and creating a line chart. How can I paste it into MSWORD?
any help is much appreciated.
so far I have:
Code
Private Function rungraph850(graph850 As Variant) As Variant
If (graph850 = "") Or (graph850 = "False.xls") Then
Exit Function
End If
Workbooks.Open (graph850)
Dim wordApp As Word.Application
Dim wordDoc As Word.Document
Set wordApp = New Word.Application
Set wordDoc = wordApp.Documents.Open(ThisWorkbook.Path & "\temp.doc")
Dim xlApp As Excel.Application
Dim xlchart As Excel.chart
xlchart.ChartType = xlLine
Dim R As Integer
With Sheets("Sheet1")
For R = 0 To 390
If (ActiveSheet.Range("A1").Cells(R + 1, "A") Like "*Channel*") Then
With xlchart
xlchart.XValues = (R - 21) / 3 + 128
xlchart.Values = graph850.Range("A1").Cells(R + 3, "D").Value
xlchart.Name = "850"
End With
End If
Next R
End With
Application.ThisWorkbook.Activate
Sheets("Sheet1").Activate
ActiveSheet.ChartObjects("xlchart").Copy
wordApp.Activate
With wordApp.Selection
.PasteSpecial DataType:=wdPasteMetafilePicture
.TypeParagraph
End With
wordApp.ActiveDocument.Save
'wordApp.ActiveDocument.Close
Set wordApp = Nothing
Set wordDoc = Nothing
End Function
Display More