Solved

Pasting a chart to Word and getting reference to the new object

Posted on 2006-11-22
6
155 Views
Last Modified: 2010-04-30
I am construction an add-in (VB.NET) that links to Excel and Word to transfer data and Charts accross.

I am able to paste the chart in using RangeObject.PasteSpecial... but what I then need to do is immediately be able to reference the new object so that I can adjust size etc.

The range object doesn't expand to encompass the new image and there are varying numbers of other shapes in the documents I am working with so I am not sure how else to reference it.

0
Comment
Question by:CarlPritchard
  • 3
  • 3
6 Comments
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 17996954
You could step back until you find it.

    Dim rng As Range
    Dim ilsh As InlineShape

    Set rng = Doc.Bookmarks("bmkOne").Range
    rng.PasteSpecial Link:=False, DataType:=wdPasteOLEObject, Placement _
        :=wdInLine, DisplayAsIcon:=False
    Do Until rng.InlineShapes.Count = 1
        rng.MoveStart wdCharacter, -1
        rng.Select
    Loop
    Set ilsh = rng.InlineShapes(1)
    MsgBox ilsh.OLEFormat.ClassType
0
 
LVL 6

Author Comment

by:CarlPritchard
ID: 18003870
Thanks, I will try that tomorrow. I will need to tweak it a bit as I am using EnhanceMetafile an not using Range.Select at all for this but will have a go.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 18004581
EnhanceMetafile?

What's that? Is it relevant to your question?
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 6

Author Comment

by:CarlPritchard
ID: 18004781
It is a pastespecial type for pictures. It allows charts and more importantly, other types of object to be pasted as a picture (not using OLE means the file size is smaller and has less compatability problems when forwarded outside the company.

Enhanced Metafile is better for large and complex tables and charts. OLE will maintain it as an Excel chart which is not what we need for a final report being sent to customers.

In theory (but I need to test this) is shouldn't stop it working.
0
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 500 total points
ID: 18004871
OK.This hasn't appeared as an option in my Paste dialogue. Maybe that's because I'm still on Win 2000

all the best, Graham
0
 
LVL 6

Author Comment

by:CarlPritchard
ID: 18007132

Yep - that worked perfectly, thanks for the help!!
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question