|
Hi All
i have come across a little problem ..
i am using excel object to create excel file from some data ..
problem is that im using office 2003 object and ma client is using office 2000.
my method
excelworksbook.open()
takes 15 parameter but in 2000 it takes just 13 parametes so it causes problem....
2nd
in excel 2000 the function is cell.value2()
while in 2003 it is cell.value()
client can not use office 2003 and i have no time to completly wewrite the code
SO IS THERE ANY WAY THAT MY APPLICATION CAN WORK FOR Excell 2000 AS WELL
with as minimum changes as possible
explore the world of imagination and be known as creative
|
|
|
|
|
i think u cn get the excel version from the registry and then write code accordingly ie
if(excel 2000 is used){
code here:
}
else{
code here:
}
Chaos, panic and disorder - my work here is done.
|
|
|
|
|
|
im new here i've always liked this site.
sorry but this is very urgent.
It wont throw that exception unless im debugging it with breakpoints, and it will throw prematurely in debug mode with breakpoints. I am using a timer for this. I dont know why it isnt reaching the if statement or its passing it up or something. Thanks for the help in advance.
[code]
private static void SecondChangedEvent(object source, ElapsedEventArgs e)
{
//sleep for 10 milliseconds.
Thread.Sleep(10);
//i use temp to check the seconds.
//error if not setting it to something.
int temp = DateTime.Now.Second;
seconds++;
Thread.Sleep(250);
//will throw an exceptionn if the seconds value is greater than 120.
//But that is handeled in DepositEnvelope().
if(seconds >= 120)
{
Exception ex = new Exception();
throw ex;
}
}
[/code]
|
|
|
|
|
Where is seconds declared and initialized? Is it set anywhere else in code? Where is SecondChangedEvent hooked up to the timer? What is the interval of the timer? What is the scope of the timer?
At first glance I would say that just because you are incrementing "seconds" in your timer handler, it's not a count of actual seconds (even if your timer is suppose to fire every second). It is better to save the start time when you start your timer, then calculate the numer of seconds that has passed.
private DateTime startTime = DateTime.Now;
private static void SecondChangedEvent(object source, ElapsedEventArgs e) {
TimeSpan span = DateTime.Now - startTime;
Int32 seconds = span.TotalSeconds;
}
Take care,
Tom
-----------------------------------------------
Check out my blog at http://tjoe.wordpress.com
|
|
|
|
|
that happened to not work for some reason i have no idea why it still doesn't work. thanks anyway. anyone else have a suggestion.
|
|
|
|
|
Hi,
your code is rather mysterious:
- where is seconds declared and initialized?
- why are you including Thread.Sleep() in an event handler? that is generally a bad idea,
since it disables the normal event processing, and here I see no reason.
- anyway, Thread.Sleep(10) will NOT delay execution for 10 milliseconds; it will be anywhere
from 16 to much much more; you could read my timers article to learn more about it.
- if you want some code to run after 120 seconds have elapsed, why not just store the
time at the start of that period, then compare "now" with start+120 as in:
DateTime endTime=DateTime.MaxValue;
...
endTime=DateTime.Now.AddSeconds(120);
...
if (DateTime.Now >= endTime) {
endTime=DateTime.MaxValue;
...
}
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|
|
Hi!
I'm writing a C# application that is using some functions in a Visual Basic 6 ActiveX dll. The problem is that some of these functions use user-defined types as arguments. How can I call these functions?
I have tried creating a c# Struct that looks exactly like the Type in Visual Basic, but when I try to call the vb-dll-function with this struct as an argument, I get an error message that says something like: "Old format or invalid type library".
|
|
|
|
|
Those types must be public. Since they're COM objects, you should be able to create user-defined types in C#, even though they were defined in VB.
|
|
|
|
|
Hmm, ok...sounds good. Any clue how I can do that?
Simplified the VB6 ActiveX dll-code looks like this:
<br />
Public Type MyType<br />
Text As String<br />
Number As Integer<br />
End Type<br />
<br />
Public Function ShowMsgBox(Msg As MyType)<br />
MsgBox Msg.Text & VbCrLf & Msg.Number<br />
End Function<br />
Calling the function from C# I do like this:
<br />
Type COMType = Type.GetTypeFromProgID("MyDLLProject.MyDLLClass", true);<br />
object UnknownObject = Activator.CreateInstance(COMType);<br />
UnknownObject.GetType().InvokeMember("ShowMsgBox", System.Reflection.BindingFlags.Default | System.Reflection.BindingFlags.InvokeMethod, null, UnknownObject, new object[] {XXXXXXXX});<br />
Where the XXXXXX is I really don't know what to put...
If it would have been ShowMsgBox(Msg As String), then no probs, I'd just put a string there, but now??
-- modified at 6:21 Monday 19th November, 2007
|
|
|
|
|
Instead of doing all this late-binding stuff, just add a reference in your project to your VB6 dll. Visual Studio will use the AxImp.exe tool in the .NET framework to generate a .NET-to-COM interop dll. From there, in C# you can use the types defined in the interop dll as if they were regular .NET types.
|
|
|
|
|
Thanks, sounds a bit easier that way, yes.
Problem is that I would prefer to have a late-binding since the dll won't always be present. It will work as a kind of a "plug-in" that some have and some haven't and I don't want to have to rebuild the whole app depending on which customer is going to have it. :-/
|
|
|
|
|
Have you looked up C# COM late binding? I just did a google search and found a good hit[^].
|
|
|
|
|
Well, I have. I feel like I've googled my brains out for this. All I've found is that it seems to be possible, but not HOW!
Thanks for the link it contains almost what I need, unfortunately it only shows how to pass an ordinary variable (a boolean). My dll requires a user-def type, question is how to "build" a similar type in c# (or how to convert a c# struct to a vb type maybe)?
|
|
|
|
|
I found an "intermediate" solution - to make another dll containing the user-def types (as these aren't changed that often) and add this as a reference in both the C# application and the Vb6 dll.
That way I can call the main dll with late binding, both c# and vb recognize the Type / Struct and I don't have to rebuild the app when I change the dll's functions. Until I decide to change the Types of cause...
It's not the ultimate solution, but I think it'll work.
Thank you for the help!
|
|
|
|
|
Hi All:
I want to create a program that have the ability to start sending & recieving information by bluetooth using c#, so please what are the basics steps I must do it before starting create this program.....
|
|
|
|
|
|
I would like to securely hide a connection string from anyone trying to break my C# assembly. I know I cannot just stick my connection string within my C# assembly because the use of Reflection would reveal it. Even through an Obfuscator the connection string can be somewhat hidden but not very securely. Putting the connection string in the app.config file and having Visual Studio automatically encrypt it is still not very secure in my eyes. I was thinking about storing it within a C++ unmanaged dll to prevent the use of reflection but I dont know if that is secure and also how do would I stop someone else from using that C++ unmanaged dll?
Has anyone found a good method out there that can be totally secure without using third party software and without using a web server?
Chris
|
|
|
|
|
|
For actual security you would need a password to be entered on application startup allowing you to use the System.Security.Cryptography namespace's cryptography classes.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
How to change the batch file icon to designed icon
naveen
|
|
|
|
|
you can only replace the icon for all batch files! a bat file can't contain any kind of resources.. bat files have only very limited features!
|
|
|
|
|
ok thanks,
How replace the icon for all batch files
naveen
|
|
|
|
|
open windows explorer - tools - folder options - file types.. select the file extension and press advanced - select icon.
|
|
|
|
|
You could create a shortcut to your batch file, and change the icon of the shortcut,
maybe that is sufficient for what you need.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use PRE tags to preserve formatting when showing multi-line code snippets
|
|
|
|