Hi all,
Using C#, I've created a simple wrapper class for using Excel. I have
Office Pro 2003 installed on my devel machine. The wrapper class works
great, reading and writing to/from Excel. To do this, I created a
reference to "Microsoft Excel 11.0 Object Library", and have a "using
Excel;" directive.
I decided to add a method for creating a TextBox using the
Shapes.AddTextBox method, which requires a
Microsoft.Office.Core.MsoTextOrientation as a parameter. Unfortunately,
I can't find what I need to reference to get the Microsoft.Office.Core
namespace into my project. I've tried adding references to "Microsoft
Office 11.0 Object Library" in COM, but that didn't provide me with the
needed namespace.
I then added a reference to "Office" (version 11.0.0.0) in the GAC, and
received the following errors:
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,10 ) : error CS0012: The
type 'Microsoft.Office.Core.MsoTextOrientation' is defined in an
assembly that is not referenced. You must add a reference to assembly
'office, Version=11.0.0.0, Culture=neutral,
PublicKeyToken=71e9bce111e9429c'.
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,20 ) : error CS1502: The
best overloaded method match for
'Excel.Shapes.AddTextbox(Microsoft.Office.Core.Mso TextOrientation,
float, float, float, float)' has some invalid arguments
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(305,17 ) : error CS1503:
Argument '1': cannot convert from
'Microsoft.Office.Core.MsoTextOrientation
[c:\WINDOWS\assembly\GAC\Office\7.0.3300.0__b03f5f7 f11d50a3a\Office.dll]'
to 'Microsoft.Office.Core.MsoTextOrientation []'
Any help would be greatly appreciated,
Michael 5 49737
Michael Russell wrote: Hi all,
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,10 ) : error CS0012: The type 'Microsoft.Office.Core.MsoTextOrientation' is defined in an assembly that is not referenced. You must add a reference to assembly 'office, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,20 ) : error CS1502: The best overloaded method match for 'Excel.Shapes.AddTextbox(Microsoft.Office.Core.Mso TextOrientation, float, float, float, float)' has some invalid arguments D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(305,17 ) : error CS1503: Argument '1': cannot convert from 'Microsoft.Office.Core.MsoTextOrientation [c:\WINDOWS\assembly\GAC\Office\7.0.3300.0__b03f5f7 f11d50a3a\Office.dll]' to 'Microsoft.Office.Core.MsoTextOrientation []'
Any help would be greatly appreciated, Michael
No one has any input? This is a real problem for me, I could really use
some pointers.
Michael
Hi Michael,
Without seeing your code also, it is hard to tell what the exact problem is.
Maybe something accidentally got out of whack with changing references and
all. Try this to get things back to normal:
1. Delete the "Excel", "Microsoft.Office.Core", and "VBIDE" references from
your project.
2. Right-click on References and select "Add Reference"
3. Click the COM tab.
4. Select Microsoft Excel 11.0 Object Library and click OK.
5. You should see Excel, Microsoft.Office.Core, and VBIDE in your
references list.
If you don't see those items (from #5) in your references list, you may not
have Office PIAs installed properly. You may have to uninstall and
reinstall them. Another alternative is to go into the Excel installation
process and find the process that allows you to select which components are
installed. There is an option to install .NET or Managed code
programability options, which will ensure PIAs are installed for you.
Here's some code I ran to try to reproduce your problem. However, following
the procedures I used above, it worked just fine:
using System;
using System.Collections.Generic;
using System.Text;
namespace OfficeAppTest
{
class Program
{
static void Main(string[] args)
{
Microsoft.Office.Core.MsoTextOrientation orientation =
Microsoft.Office.Core.MsoTextOrientation.msoTextOr ientationHorizontal;
}
}
}
Your error message also indicates that it is possible that the method you
are trying to use takes only a single instance of MsoTextOrientation, but
you are trying to give it an array of MsoTextOrientation
(MsoTextOrientation[]), which are different types.
If you do post some code, you should make it the smallest example possible
that I can cut-and-paste so I can see the problem for myself. A large
listing that doesn't compile is often not much use.
Joe
-- http://www.csharp-station.com
"Michael Russell" <mr*******@hotmail.com> wrote in message
news:uX**************@TK2MSFTNGP02.phx.gbl... Michael Russell wrote: Hi all,
D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,10 ) : error CS0012: The type 'Microsoft.Office.Core.MsoTextOrientation' is defined in an assembly that is not referenced. You must add a reference to assembly 'office, Version=11.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c'. D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(303,20 ) : error CS1502: The best overloaded method match for 'Excel.Shapes.AddTextbox(Microsoft.Office.Core.Mso TextOrientation, float, float, float, float)' has some invalid arguments D:\Work\CSharp\ExcelWrapper\ExcelWrapper.cs(305,17 ) : error CS1503: Argument '1': cannot convert from 'Microsoft.Office.Core.MsoTextOrientation [c:\WINDOWS\assembly\GAC\Office\7.0.3300.0__b03f5f7 f11d50a3a\Office.dll]' to 'Microsoft.Office.Core.MsoTextOrientation []'
Any help would be greatly appreciated, Michael
No one has any input? This is a real problem for me, I could really use some pointers.
Michael
Joe Mayo [C# MVP] wrote: Hi Michael,
Without seeing your code also, it is hard to tell what the exact problem is. Maybe something accidentally got out of whack with changing references and all. Try this to get things back to normal:
1. Delete the "Excel", "Microsoft.Office.Core", and "VBIDE" references from your project. 2. Right-click on References and select "Add Reference" 3. Click the COM tab. 4. Select Microsoft Excel 11.0 Object Library and click OK. 5. You should see Excel, Microsoft.Office.Core, and VBIDE in your references list.
Tried this, VBIDE and Microsoft.Office.Core never appear in the list of
references. If you don't see those items (from #5) in your references list, you may not have Office PIAs installed properly. You may have to uninstall and reinstall them. Another alternative is to go into the Excel installation process and find the process that allows you to select which components are installed. There is an option to install .NET or Managed code programability options, which will ensure PIAs are installed for you.
Using Office 2003 setup, removed then reinstalled the .Net Programming
support for all the components of Office, the problem remains unchanged.
I also made sure that I've downloaded the SP and updates for Office 2003.
FWIW, while reinstalling the support from the CD, I noticed that it said
that the support is for version 1.1 of the .Net Runtime; the PIA
redistributable on Microsoft's web site also says that 1.1 is required,
no mention of 2.0 or "1.1 or higher". Perhaps this is my problem?
<Sample code deleted> Your error message also indicates that it is possible that the method you are trying to use takes only a single instance of MsoTextOrientation, but you are trying to give it an array of MsoTextOrientation (MsoTextOrientation[]), which are different types.
If you do post some code, you should make it the smallest example possible that I can cut-and-paste so I can see the problem for myself. A large listing that doesn't compile is often not much use.
The section of code where I need the Microsoft.Office.Core reference:
Excel.Shapes shapes = xlWks.Shapes;
xlShape = shapes.AddTextbox(
MsoTextOrientation.msoTextOrientationHorizontal,
(float)left, (float)top, (float)width, (float)height );
I don't think it's a problem with the code, but it won't compile because
I'm unable to get a reference to Microsoft.Office.Core.
Thanks,
Michael
"Michael Russell" <mr*******@hotmail.com> wrote in message
news:uO****************@TK2MSFTNGP04.phx.gbl... Joe Mayo [C# MVP] wrote: Hi Michael,
Without seeing your code also, it is hard to tell what the exact problem is. Maybe something accidentally got out of whack with changing references and all. Try this to get things back to normal:
1. Delete the "Excel", "Microsoft.Office.Core", and "VBIDE" references from your project. 2. Right-click on References and select "Add Reference" 3. Click the COM tab. 4. Select Microsoft Excel 11.0 Object Library and click OK. 5. You should see Excel, Microsoft.Office.Core, and VBIDE in your references list.
Tried this, VBIDE and Microsoft.Office.Core never appear in the list of references.
If you don't see those items (from #5) in your references list, you may not have Office PIAs installed properly. You may have to uninstall and reinstall them. Another alternative is to go into the Excel installation process and find the process that allows you to select which components are installed. There is an option to install .NET or Managed code programability options, which will ensure PIAs are installed for you.
Using Office 2003 setup, removed then reinstalled the .Net Programming support for all the components of Office, the problem remains unchanged. I also made sure that I've downloaded the SP and updates for Office 2003.
FWIW, while reinstalling the support from the CD, I noticed that it said that the support is for version 1.1 of the .Net Runtime; the PIA redistributable on Microsoft's web site also says that 1.1 is required, no mention of 2.0 or "1.1 or higher". Perhaps this is my problem?
<Sample code deleted>
Your error message also indicates that it is possible that the method you are trying to use takes only a single instance of MsoTextOrientation, but you are trying to give it an array of MsoTextOrientation (MsoTextOrientation[]), which are different types.
If you do post some code, you should make it the smallest example possible that I can cut-and-paste so I can see the problem for myself. A large listing that doesn't compile is often not much use.
The section of code where I need the Microsoft.Office.Core reference:
Excel.Shapes shapes = xlWks.Shapes; xlShape = shapes.AddTextbox( MsoTextOrientation.msoTextOrientationHorizontal, (float)left, (float)top, (float)width, (float)height );
I don't think it's a problem with the code, but it won't compile because I'm unable to get a reference to Microsoft.Office.Core.
I was able to get it to work like this:
Excel.Shapes shapes = xlWks.Shapes;
xlShape = shapes.AddTextbox(
Microsoft.Office.Core.MsoTextOrientation.msoTextOr ientationHorizontal,
(float)left, (float)top, (float)width, (float)height );
The only thing now is to get the reference to the Microsoft.Office.Core dll.
Something is keeping it from properly adding the right proxies to your
reference list. Here's something else to try:
1. Remove the Excel, Microsoft.Office.Core, VBIDE reference from your list.
2. Close down Visual Studio to make sure it isn't holding any file locks.
Are you using Visual Studio 2003? There was a problem with this on some
machines that was similar to this, which was incredibly difficult to fix.
3. Look in the directories of your project, looking for interop assemblies.
They are named Interop.*.dll. Delete the Interop.Excel.dll,
Microsoft.Office.Core.dll, and Interop.VBIDE.dll wherever you find them.
4. Maybe reboot after that, but I'm not sure that's necessary. Perhaps
just an old habit that sometimes worked. <grin>
5. Restart Visual Studio and re-add the Microsoft Office Excel 11.0 Object
Library reference.
6. Keep your fingers crossed if it properly added a reference to
Microsoft.Office.Core.dll.
The previous steps were the ideal situation. If they don't work, try to add
the reference back from the GAC, like you did before.
Then run and see if it works.
Joe
-- http://www.csharp-station.com
Joe Mayo [C# MVP] wrote: "Michael Russell" <mr*******@hotmail.com> wrote in message news:uO****************@TK2MSFTNGP04.phx.gbl... Joe Mayo [C# MVP] wrote:
<snip>
I was able to get it to work like this:
Excel.Shapes shapes = xlWks.Shapes; xlShape = shapes.AddTextbox( Microsoft.Office.Core.MsoTextOrientation.msoTextOr ientationHorizontal, (float)left, (float)top, (float)width, (float)height );
The only thing now is to get the reference to the Microsoft.Office.Core dll. Something is keeping it from properly adding the right proxies to your reference list. Here's something else to try:
1. Remove the Excel, Microsoft.Office.Core, VBIDE reference from your list. 2. Close down Visual Studio to make sure it isn't holding any file locks. Are you using Visual Studio 2003? There was a problem with this on some machines that was similar to this, which was incredibly difficult to fix. 3. Look in the directories of your project, looking for interop assemblies. They are named Interop.*.dll. Delete the Interop.Excel.dll, Microsoft.Office.Core.dll, and Interop.VBIDE.dll wherever you find them. 4. Maybe reboot after that, but I'm not sure that's necessary. Perhaps just an old habit that sometimes worked. <grin> 5. Restart Visual Studio and re-add the Microsoft Office Excel 11.0 Object Library reference. 6. Keep your fingers crossed if it properly added a reference to Microsoft.Office.Core.dll.
The previous steps were the ideal situation. If they don't work, try to add the reference back from the GAC, like you did before.
Then run and see if it works.
Joe
Joe,
Thanks for following up on this. I'm not running VS, but SharpDevelop
2.0. To verify the problem, though, I downloaded Visual C# Express and
loaded my code into it to see what would happen. Sure enough, when I
added the reference to Excel in COM, the references to
Microsoft.Office.Core and VBIDE appeared just as they should.
So, the problem appears to be limited to SharpDevelop, and I've
submitted this to them to find out what's going on. Again, thanks for
the follow-up, it helped to have someone verify that I wasn't doing
something wrong in my part.
Michael This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Helene Day |
last post by:
I am trying to access the Word Objects from a .NET project.
I have some sample from
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/odc_vsto2003_ta/html/WordObject.asp
and I...
|
by: Tomas Vera |
last post by:
Hello All
I have a project that references Interop.Microsoft.Office.Core
But when I try to build, I get this error
Exception from HRESULT: 0x80131019. (3 times)
followed by
The dependency...
|
by: AllenF |
last post by:
I have a library (named DSG) created in C# which other programs use to build
Excel spreadsheeets. This library uses the office PIAs
"Microsoft.Office.Interop.Excel.dll" and also references the...
|
by: Simon |
last post by:
Overnight, I've developed this error somehow, when I try to build/run my
application:
"Parser Error Message: Unable to load file 'Interop.Microsoft.Office.Core'."
I'm pretty sure I haven't...
|
by: ns2k |
last post by:
I tried to implements Microsoft.Office.Core.Range Interface, but the
dot net raise errors :
+ ' '_Default' cannot implement '_Default' because there is no
matching property on interface 'Range'.'...
|
by: William LaMartin |
last post by:
I have created a program that allows for the automation of things in Word
documents, like changing the values of DocVariables and the links to Excel
Sheets. I did it using interoperoperatability,...
|
by: Alan T |
last post by:
VS 2005 and MS Office 2003 installed.
I can include Microsoft.Office.Core and Word in the references so I can add
the
using Microsoft.Office.Interop.Word.
However, my workmate cannot do the...
|
by: spinz2112 |
last post by:
Im trying to create a windows utility that opens an excel file in VS2005 using C#. Everything that I have found on the web says the first thing to do is to add a reference to the MS Excel 10 Object...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |