views:

87

answers:

2

I'm trying to create a linked OLE Object in a Word document using VB.Net.

Existing code uses InlineShapes.AddOLEObject(FileName:="abc.xlsx", LinkToFile:=True, Range:=Some Word Range) to insert a worksheet into a Word document.

I need more control than this. To select a range of cells I've found that extra information after the filename can be useful, for example: FileName:="abc.xlsx!sheet1!R1C1:R20C5"

Is there a way to specify a specific chart within a worksheet? So can I specify the second chart on the worksheet as the object to link to?

Thanks.

A: 

A chart will either be a whole worksheet so address as per your sheet1 e.g. abc.xlsx!sheet1 or an object on a sheet so use the object name e.g. abc.xlsx!sheet1!chart_object

Mark
When I tried that (last week and again just now), the code just hangs...If that is the way to achieve it, then I will need to delve a little deeper into the code and see what the problem is.Thanks for your help :)
Hannah
A: 

Thanks for your help Mark.

I eventually figured out that if the Chart is in it's own sheet, rather than an object in Sheet1, then the AddOLEObject code works correctly with the following setting:

FileName:="abc.xlsx!Chart1"

I'm happy with this solution.

Hannah