Excel VBA Program to Copy All the charts present in the Activesheet & paste into word file and then Print the word file.......
Sub Copy_charts_into_word()
Dim doc As New Word.Application ''' tools->reference->microsoft word 12.0 object library
doc.Documents.Add
doc.Visible = 1
For i = 1 To ActiveSheet.ChartObjects.Count
Sheet1.ChartObjects(i).Copy
Word.Selection.Range.PasteSpecial DataType:=wdPasteMetafilePicture, Placement:=wdInLine
Word.FindKey(KeyCode:=BuildKeyCode(wdKeyEnd)).Execute
Word.Selection.TypeParagraph
Word.Selection.TypeParagraph
Next
Word.ActiveDocument.PrintOut
Word.ActiveDocument.Save
doc.Quit
Set doc = Nothing
End Sub
Sample file for the above VBA Program:----------------------------
Sub Copy_charts_into_word()
Dim doc As New Word.Application ''' tools->reference->microsoft word 12.0 object library
doc.Documents.Add
doc.Visible = 1
For i = 1 To ActiveSheet.ChartObjects.Count
Sheet1.ChartObjects(i).Copy
Word.Selection.Range.PasteSpecial DataType:=wdPasteMetafilePicture, Placement:=wdInLine
Word.FindKey(KeyCode:=BuildKeyCode(wdKeyEnd)).Execute
Word.Selection.TypeParagraph
Word.Selection.TypeParagraph
Next
Word.ActiveDocument.PrintOut
Word.ActiveDocument.Save
doc.Quit
Set doc = Nothing
End Sub
Sample file for the above VBA Program:----------------------------
No comments:
Post a Comment