473,385 Members | 1,821 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Excel OLE linking

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
1 3731
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mark T. | last post by:
Hi, I've got a simple DB (Office Win XP Professional). Basically, it's like a check book register - deposit, deduction and running sum. I'd like to somehow link it to an Excel spreadsheet that...
8
by: Nick M | last post by:
Hello All, Excellent info here Thanks! I am very new to using access in general and I am on a learning curve. I'm trying to import an excel workbook (with worksheets) into an access db via a...
1
by: c duden | last post by:
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...
0
by: Grip | last post by:
Hi, I have gone throught the group and Microsoft's online help and have seen many suggestions but I am still seeking clarity: 1. I have an excel spreadsheet. Column A contains text that may...
6
by: oyk | last post by:
I hope someone could help me on this. I have linked an excel worksheet to access but the some data shown in the access table has the #Num errors. Presumably, this must be because the data in the...
6
by: jalmar | last post by:
Hello again: My second question is: I am linking an excel spreadsheet into Access, I have it linked and at first had problems getting the information imported into Access-it wasn't importing-I...
0
by: Sajit | last post by:
I am trying to use an Excel file as a template for an Access report. I Linked the Excel file through an unbound frame as an OLE object with the properties set as follows: Source Doc...
1
by: karthik28 | last post by:
I tried linking an excel spreadsheet to an access database. It shows me a window with the data but the header row in missing. However, when I open the excel file, save it without making any changes...
1
by: agarwasa2008 | last post by:
Hi, I have a perfect file called "Products.xls" that I link to my MS Access 2003 database and everytthing looks good in that file. When I view the same file after linking in my database the...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.