+ Reply to Thread
Results 1 to 3 of 3

extract graph excel to word in VBA (resizing)

  1. #1
    Registered User
    Join Date
    02-17-2014
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    extract graph excel to word in VBA (resizing)

    Hi there,

    Currently, I am struggling with my script and can't seem to find an answer on the internet.
    Here is the problem. I got to the point where the script is extracting a graph from the excel sheet and is pasting it into word.
    But I want the graph to have a specific size in word. For example width: 25cm and height: 7.5cm

    It's not important if the resizing takes place in excel before it becomes pasted or afterwards when the graph already is in word.
    I would really appreciate any help on this, because I already tried a lot of combinations which don't seem to work. I'm using Office 2010.

    Sub graphimporter()
    Dim path As String
    Dim filename As String
    ' Dim wrdApp As Word.Application
    ' Dim wrdDoc As Word.Document
    path = "the location of the excel file"

    Set wrdApp = GetObject(, "Word.Application")
    Set xlapp = GetObject(, "Excel.Application")
    xlapp.DisplayAlerts = False
    xlapp.Visible = False
    wrdDoc = wrdApp.Documents.Open(thewordfileIuse.docx")

    Set xlsWbk = xlapp.Workbooks.Open(path & file)

    xlsWbk.Sheets("Samengevat_per_dag").ChartObjects(1).Activate
    xlsWbk.ActiveChart.ChartArea.Select
    xlsWbk.Sheets("the specific sheet I need").ChartObjects(1).Activate
    xlsWbk.ActiveChart.ChartArea.Select
    xlsWbk.ActiveChart.ChartArea.Copy
    With Selection
    .Paste
    End Sub

  2. #2
    Registered User
    Join Date
    02-17-2014
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: extract graph excel to word in VBA (resizing)

    After .Paste, I was thinking about something like:
    With Selection
    .InlineShape.height = 250
    .InlineShape.width = 100
    End With

    It doesn't seem to work.
    Last edited by 1990b; 02-18-2014 at 06:30 AM.

  3. #3
    Registered User
    Join Date
    02-17-2014
    Location
    Amsterdam, Netherlands
    MS-Off Ver
    Excel 2010
    Posts
    3

    Re: extract graph excel to word in VBA (resizing)

    All right this seems to work now. After the graph is pasted into word it recognizes this as shape(1).
    But I have a lot of graphs and I don't want to assign numbers to all these shapes. Is there a way to alter
    the inlineshapes() somehow in order to only resize a shape to the one which is last pasted??


    With ActiveDocument.InlineShapes(1)
    .Width = CentimetersToPoints(25)
    .Height = CentimetersToPoints(7.5)
    Last edited by 1990b; 02-18-2014 at 06:44 AM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Pasting as image from excel to word (2010) and resizing
    By Alexander_Golinsky in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 08-08-2012, 10:39 AM
  2. Extract a text from word and place it en excel or word?
    By Elegidos in forum Word Programming / VBA / Macros
    Replies: 1
    Last Post: 12-09-2009, 06:14 AM
  3. Exporting Word Chart to Excel (Resizing Chart)
    By bg18461 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 05-12-2008, 11:49 AM
  4. Resizing graph in Word using VBA...
    By newbie108 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-15-2007, 01:56 PM
  5. [SOLVED] Automatically Resizing a Graph
    By PaulW in forum Excel General
    Replies: 1
    Last Post: 04-13-2006, 11:20 AM

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.6.0 RC 1