Solved

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

Posted on 2006-11-22
6
156 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

696 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