+ Reply to Thread
Results 1 to 5 of 5

Thread: Exporting Word Chart to Excel (Resizing Chart)

  1. #1
    Registered User
    Join Date
    04-28-2004
    Posts
    34

    Exporting Word Chart to Excel (Resizing Chart)

    I am currently exporting a data table and a chart to a word document from my excel file with this code:
    Sub XLtoWord()
    Dim wdApp As Word.Application, wdDoc As Word.Document, ws As Worksheet
    Dim wdInfo Word.Range
    Dim sTemps As String
    Dim myNamed As Excel.Range
    Dim myNamedChart As Excel.ChartArea
       Set wdApp = CreateObject("Word.Application")
       wdApp.Visible = True
     
        sTemps = "\\My\Documents\Work Graphs Template.docm"
     
        Set wdDoc = wdApp.Documents.Open(sTemps)
        Set myNamed = Sheets("EU History").Range("Table1")
        Set wdInfo= wdDoc.Goto(what:=wdGoToBookmark, Name:="Table1")
     
        myNamed.Copy
     
        wdInfo.PasteSpecial link:=False, _
            DataType:=2, _
            Placement:=0, DisplayAsIcon:=False
     
        ActiveSheet.ChartObjects("Chart 8").Activate
        ActiveChart.ChartArea.Copy
     
        Set wdInfo= wdDoc.Goto(what:=wdGoToBookmark, Name:="Chart1")
     
        With wdInfo
     
        .PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, Placement:= _
        wdFloatOverText, DisplayAsIcon:=False
        .ShapeRange.LockAspectRatio = msoFalse
        .ShapeRange.Height = 3.89
        .ShapeRange.Width = 7.22
     
        End With
    My issue is that I can't seem to resize the chart from within excel. I probably could do inside word once the chart is pasted, but I would rather leave my code inside excel. The .shaperange... does not have an effect on the chart size inside word. Any ideas?

  2. #2
    Registered User
    Join Date
    04-28-2004
    Posts
    34
    Any ideas ttt

  3. #3
    Registered User
    Join Date
    04-28-2004
    Posts
    34
    Please, does anyone have any ideas...

  4. #4
    Registered User
    Join Date
    04-28-2004
    Posts
    34
    ttt, please any help

  5. #5
    Forum Guru Andy Pope's Avatar
    Join Date
    05-10-2004
    Location
    Essex, UK
    MS-Off Ver
    2003 & 2007 & 2010
    Posts
    11,351
    Try this modification to the end of your code.

        With wdInfo
     
         .PasteSpecial link:=False, DataType:=wdPasteEnhancedMetafile, Placement:= _
                        wdFloatOverText, DisplayAsIcon:=False
        End With
        With wdDoc.Shapes(wdDoc.Shapes.Count)
            .LockAspectRatio = msoFalse
            .Height = 3.89
            .Width = 7.22
        End With
    Also, you may need to rethink those height and width values as the shape is in points not cm's.

    Height= 110.6342
    Width = 204.6614
    Cheers
    Andy
    www.andypope.info

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.2.0