Place Excel Chart in Microsoft Word Document with vb.net

Good Morning! Well my time publish didn’t work like I wanted it to. But that’s okay I am sure I did something wrong.

My night was not great. But lets leave it at that.

Anyway, yesterday’s post we created a chart in Excel and now we want to put that chart into a Microsoft Word Document. Not complicated stuff now but it drove me nuts for a while.

Make it a great day!


Join me on Facebook

‘ASSUMED

‘Dim Word As Word.Application

‘Dim WSheet As New Excel.Worksheet
‘       WSheet = Excel.Workbooks.Add.Worksheets.Add

Label3.Text = "Creating Word Table…."
        Word.Application.ActiveWindow.ActivePane.Document.Tables.Add(Range:=Word.Application.ActiveWindow.ActivePane.Document.Content.Application.Selection.Range, NumRows:=3, NumColumns:= _
                                1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _
                                wdAutoFitFixed)

Label3.Text = "Adding RX Chart to Word Document……"

        Excel.Application.Sheets("AddedTotalsChart").Select()
        WSheet3.Application.ActiveChart.CopyPicture( _
                                       Appearance:=1, Size:=1, Format:=-4147)
        Word.Application.ActiveWindow.Selection.Tables.Item(1).Cell(1, 1).Range.Select()
        Word.Application.ActiveWindow.Selection.PasteSpecial(Link:=False, DataType:=3, _
                    Placement:=0, DisplayAsIcon:=False)

       

Technorati Tags: ,,,,,,,,,,,,,,,,
,,,,,,,,,,,
,,,,,

Advertisements
  1. #1 by Murali Krishna on June 9, 2009 - 1:00 pm

    Thanks Kelly, this article helped me to pul fullstop to my problem.Regards, Murali

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: