|
I am trying to automate Excel from within my C# application, and am receiving the above error.
I have added a reference in my project to the Microsoft Excel 12.0 object library which adds the Microsoft.Office.Core and Microsoft.Office.Interop.Excel namespaces (but strangely not the the Excel namespace - this is is only added when I add a reference to the Microsoft Excel 5.0 object library).
I have downloaded the latest Primary Interop Assemblies (PIA) for Microsoft Office from the MS download site, and added the following code to my program as well:
using Excel;
I still get the error. I have run out of ideas!!
Any help much appreciated.
|
|
|
|
|
Instead of "using Excel;" you should have "Microsoft.Office.Interop.Excel;" or you can create an aliases for that like this: "using ExcelInterop = Microsoft.Office.Interop.Excel;"
Giorgi Dalakishvili
#region signature
my articles
#endregion
|
|
|
|
|
"Cannot create an instance of the abstract class or interface 'Excel.Application"
You cannot create instances of abstract classes or interfaces... Also, I don't see how your question has anything to do with this title.
Excel is not the namespace, use Microsoft.Office.Interop.Excel.
Cheers,
|
|
|
|
|
Please me Remoting concept of dot net in detail
---
Regards
ilango gandhi
' Knowledge can only be got in one way, the way of experience; there is no other way to know.'
|
|
|
|
|
ilango gandhi wrote: Remoting concept of dot net
The concept is like taking two tin cans and linking them together with a string.
led mike
|
|
|
|
|
|
|
You have a habit of asking very general questions that could be answered with the use of Google. Please study the language, and then come back with specific questions.
|
|
|
|
|
Hi,
I need help to create something like a news ticker. I want text to scroll from the right site of the screen to the left. I've been playing around with a DoubleAnimation but than you won't get a continuasly stream of text and it won't show all the text that is my TextBlock wich is in a UserControl.
I don't wan't to use substring to remove characters because this doesn't give a smooth animation.
I'm using C# code in a WPF project.
Thanks
Kevin
|
|
|
|
|
KBou wrote: DoubleAnimation
KBou wrote: WPF
Oh, you did say it was WPF. I suggest using the WPF forum.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I have a service that launches multiple threads. Each thread has a unique purpose and thus they are unique sources. I have a successfully created log file named OneSource and I want all of the sources logging events to that log file.
Currently I have each thread initializing and accessing the EventLog with their own instances, the service itself does not do any logging. My first thread that I start successfully initialized and logs to the file but subsequent ones do not. Here is my eventlog initialization logic (some names were changed to protect the innocent :
#region Eventlog initialization
bool creationNeeded = false;
if ( !EventLog.SourceExists( "someSource" ) )
creationNeeded = true;
else if ( !EventLog.LogNameFromSourceName( "someSource", "." ).Equals( "OneSource" ) )
{
creationNeeded = true;
EventLog.DeleteEventSource( "someSource" );
}
if ( creationNeeded )
{
EventLog.CreateEventSource( "someSource", "OneSource" );
}
events = new System.Diagnostics.EventLog( "OneSource", ".", "someSource" );
events.WriteEntry( "someSource: Event log successfully started.", EventLogEntryType.Information );
#endregion
FYI: We had management constantly changing their minds on the log file to use so we had to add code to make sure that the old log was deleted before we used the new logfile name and source.
I see the initialization message from sourceOne, but not from sourceTwo or sourceThree. Nor do I see any logged messages from anything but sourceOne. Also...I see Information logged entries from sourceOne, but I never see anything logged where I use an AuditSuccess state for the log event.
Any guidance would be appreciated.
|
|
|
|
|
Wow, is that production code with all those string literals? Are you kidding me?
LongRange.Shooter wrote: I see the initialization message from sourceOne, but not from sourceTwo or sourceThree.
Well I don't see any string literals for anything but someSource and OneSource in the code you posted so based on that seeing anything else is just not possible, period.
ASIDE: The code you posted is horrible, literally.
led mike
|
|
|
|
|
Well, smartass, you don't see it because it is just the initialization code for someSource. The other initialization routines are the same, but someSource is replace with anotherSource, finalSource (for example). It is representative code of the initialization routine. And, BTW, in a recent technology testing I took I rated in the top 5% internationally as a C# coder.
So do you have anything helpful to add or do you just like hearing yourself blow crap out your mouth?
|
|
|
|
|
F*** off a**hole
led mike
|
|
|
|
|
LongRange.Shooter wrote: in a recent technology testing I took I rated in the top 5% internationally as a C# coder.
So was it an easy test then?
Bob
Ashfield Consultants Ltd
|
|
|
|
|
No it was the Robert Half test, locally most got only 75% and internationally the average was 79% while I scored 92%.
|
|
|
|
|
Oh, I see. I've looked Robert Half up now, I didn't realise they were a recruitment agency, I thought they were a just a certification company, like say CompuTeach here in the UK.
Obviously their tests will carry a lot of weight in the development community
Bob
Ashfield Consultants Ltd
|
|
|
|
|
Let me get this staight...someone who is a site MVP and appears to be much more experienced than you told you that your code was not good. Yeah, he could have said it better, but calling him names is going to get you ignored permanently.
LongRange.Shooter wrote: in a recent technology testing I took I rated in the top 5% internationally as a C# coder.
Don't make claims like this unless you can prove it.
|
|
|
|
|
Well, first of all I don't care who or what he is. He could answer the question or shut up. He did not answer the question nor did he behave in a fashion I'd expect of a site MVP. Secondly, his comment was one of a smartass not someone being helpful. Finally, my claim can be backed up by anyone that has access to the Robert Half testing scores...the results showed that locally here the average score was 72 and internationally it was 79 while I score 93.
As to more experience....I've not seen anything that indicates he has more experience than me, especially since I've been writing code for 30 years and he's only been at it 15 years. I was also in a group that was part of the C# early adapters program and was working with Microsoft in finalizing the language within Visual Studio. Being a site MVP just means he either has no job or no life so he can jump in and answer a ton of questions before anyone else. I've been on this site for many years, been help to many people and I always try to provide help and not criticism, except where some constructive criticism can be of help.
Finally with the exception of the use of the various literals in beta code, there is nothing wrong with my code that I can see. And if there was indeed a major issue with how I wrote the code I'd love to have some one point out what it is.
|
|
|
|
|
LongRange.Shooter wrote: I have a service that launches multiple threads. Each thread has a unique purpose and thus they are unique sources. I have a successfully created log file named OneSource and I want all of the sources logging events to that log file.
A possibility exists: Is this service running under the LocalSystem account?? If so, it doesn't have the permissions to execute the EventLog.SourceExists method and will throw a SecurityException. Sources should be created by the service installer, not the service itself.
|
|
|
|
|
Hi Dave.
I'm not getting any exceptions during the process execution. But I am running under LocalSystem. I have security set to LinkDemand inheriting the rights from the service, and the service (for now) Asserts SecurityPermission. We are still in development and (as pointed out) we have a constantly changing environment at the moment. In fact we may be looking at yet another log file change in a few months just because the owning company is going to change the company name and they don't want a log file with the old name.
Thanks.
|
|
|
|
|
LongRange.Shooter wrote: I'm not getting any exceptions during the process execution.
Since it's a service that runs under a different desktop you won't see any exceptions. The reason it will fail is because that method call digs into the registry to get the information, and the bulk of the registry is off-limits to the LocalSystem account.
|
|
|
|
|
I have function I need to call from an legacy dll. The first parameter I need to pass is a pointer to a structure which contains pointers to another structure. I tried everythiing I could find on the internet and nothing has solve this issue. following are the structure:
[StructLayout(LayoutKind.Sequential,Pack = 4)]
unsafe public struct s_ci
{
public String value;
public ushort ci;
public ulong num_valid;
public ulong num_blank;
public ulong num_invalid;
public ulong num_zero;
public ulong num_alpha;
public ulong num_other;
public double total;
public ushort maxsiz;
};
[StructLayout(LayoutKind.Sequential, Pack = 4)]
unsafe public struct Name_Struct
{
[MarshalAs(UnmanagedType.LPStruct, SizeConst = 4)]
public s_ci p_npnf;
[MarshalAs(UnmanagedType.LPStruct, SizeConst = 4)]
public s_ci p_npnt;
[MarshalAs(UnmanagedType.LPStruct, SizeConst = 4)]
public s_ci p_npfn;
[MarshalAs(UnmanagedType.LPStruct, SizeConst = 4)]
public s_ci p_npmn;
[MarshalAs(UnmanagedType.LPStruct, SizeConst = 4)]
public s_ci p_npln;
};
public static extern long Evaluate_Formatted_Name([In,Out]ref Name_Struct primary,
[In,Out]ref Mask p_mask,
int last_first, UInt32 handle);
public long ProcessRfmtName(string fname, UInt32 handle)
{
long rc = 0;
//create name structure
Name_Struct p_name = new Name_Struct();
p_name.p_npnf.value = fname.ToString();
Mask p_mask = new Mask();
rc = RFMT_NAME.Evaluate_Formatted_Name(ref p_name, ref p_mask, 1, handle);
return rc;
|
|
|
|
|
LouMattera wrote: The first parameter I need to pass is a pointer to a structure which contains pointers to another structure. I tried everythiing I could find on the internet and nothing has solve this issue.
Did you try creating a managed class that wraps the function using C++/CLI so you can use the native structures?
led mike
|
|
|
|
|
No I have not. What I understand is you want me to write a managed dll in c++ to bridge to the unmanaged c dll.
|
|
|
|