By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
448,967 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 448,967 IT Pros & Developers. It's quick & easy.

Excel OLE linking

P: n/a
Excel won't allow documents to be linked to a worksheet in office 2000 when
using C# to create an add-in.

The following code snippets are what was used in the attempts
(there are more permutations of parameters, but for brevity...):

// one - based on code from Matt Reynolds' website
Excel.Worksheet active =
(Excel.Worksheet)excelApp.ActiveWorkbook.ActiveShe et;
((Excel.OLEObjects)active.OLEObjects(Type.Missing) ).Add(
classtype, path, true, false, Type.Missing,
Type.Missing, Type.Missing, 10.0F, 10.0F, 400.0F, 150.0F).Select(false);

// two
Excel.Worksheet active =
(Excel.Worksheet)excelApp.ActiveWorkbook.ActiveShe et;
((Excel.OLEObjects)active.OLEObjects(Type.Missing) ).Add(
classtype, path, true, false, Type.Missing,
Type.Missing, Type.Missing, 10.0F, 10.0F, 400.0F, 150.0F);

// three
Excel.Worksheet active =
(Excel.Worksheet)excelApp.ActiveWorkbook.ActiveShe et;
((Excel.OLEObjects)active.OLEObjects(Type.Missing) ).Add(
Type.Missing, path, true, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, 10.0F, 10.0F, 400.0F, 150.0F);
// four
Excel.Application ExcelApp = (Excel.Application)mApplication;
Excel.WorkbookClass Book = (Excel.WorkbookClass)ExcelApp.ActiveWorkbook;
Excel.Worksheet Sheet = (Excel.Worksheet)Book.ActiveSheet;

Excel.Shape Shp = Sheet.Shapes.AddOLEObject(Type.Missing, path, true,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Type.Missing);
All examples throw exceptions that state that linking cannot be performed,
the object cannot be inserted, or that the Add method failed.

Considering that the code to accomplish this in VBA is quite simple, this
problem is perplexing.
ActiveSheet.OLEObjects.Add(Filename:= _
"C:\Documents and Settings\jhamilton\My Documents\Test1.doc",
Link:=True, _
DisplayAsIcon:=False).Select

I've examined the interop assemblies to ensure that all events are public,
which I don't think is problem, but it was worth a shot. All research led me
to the above solutions, all of which failed.

Does anyone have any insight into this or an example of this working?
Thanks.
Jul 21 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi duden,

Thank you for posting in MSDN managed newsgroup!

I have replied you for this issue in
microsoft.public.office.developer.automation.

Thank you for using Microsoft NewsGroup!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

Jul 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.