Thursday, January 12, 2012

Copy All the Charts in the Excel file & Paste into Word

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:----------------------------

No comments:

Post a Comment

Excel VBA to send email from excel with HTML table in a email body

'' Excel vba script to send email from outlook & email body in HTML table format. ''Write down email body in HTML tags...