?
Solved

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

Posted on 2006-11-22
6
Medium Priority
?
159 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Industry Leaders: 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 2000 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: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses
Course of the Month12 days, 13 hours left to enroll

777 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