|
hey friends,
am developing an automation addin to excel using c#, upon building and running my project, an excel instance opens up. Now, i have somethings relevant to this excel to save to an xml. Thus, I need a seperate xml to every seperate instance of excel. For later uses I should be able to save my excel sheet and upon opening this saved sheet, I should be able to read from the corresponding xml file too! I am generating the xml file in my code itself. Thus, I need a unique name/id to name these "excel---xml" pairs and thus be able to read from the corresponding xml whenever i open any saved sheet.
more or less like.. i need... book1.xls----book1.xml & book2.xls----book2.xml & so on...
regards.
|
|
|
|
|
How about Guid.NewGuid() ?
|
|
|
|
|
but hey, i should be able to save the sheet and re open and re use the sheet and its corresponding xml right... this guid.newguid() would give every time a new globally unique identifier. This way, how can I fetch the guid of my currently opened sheet(which was saved earlier) so that I'll open the correct xml?
|
|
|
|
|
I think you must create a new Guid using Guid.NewGuid() and put that Guid in your excel sheet and xml. Then if you open it, just open the excel sheet, get the guid from that sheet, and find the same guid in xml.
|
|
|
|
|
erm.. will have to work on it..
|
|
|
|
|
Is there a way I can know whether my Instance(excel) is saved or not?! So that I can use in the OnDisconnection() part of the code?!
|
|
|
|
|
Why not use something like YourApplication00001.xls
Keep an internal counter somewhere and increment the 1 evertime it is opened.
You could even ask the user for the name to use if you wanted to.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
well, he might not save certain instances at all... nd i feel it's weird to ask something like.. would you like to save this? If yes, enter the name, because it's quite variable, if in the last moment he decides to save... hence i need something like... MyApplication.guid() or something.. I've tried using Hinstance..Index.. blah blah.. but no help.
|
|
|
|
|
I would assume that the c# DLL can get access to the user.applicationdata folder so you should be able to store the number in there. Add enough 0 so you can not reasonably run out. Not sure an xl add in has that access though.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
im currently working on a C# project which needs to program out a font dialog box.
i have searched the net but mostly of them are those kind which have to click on a button before the font dialog box pops out.But i want the font dialog box to be on my form.When i debug, i see the font dialog box and i can display my selected font on a sample box there.
Hope that someone can understand and help me.
Thanks in advance.
|
|
|
|
|
Dude for that you need to make your own . . .
You need to make buttons and generate events, etc etc. .
|
|
|
|
|
i have created the form design and i have already got the fonts from the system.
The problem is that i dun noe how to combine the different values of font,style,script and size together and get them displayed on the sample display.
Do you have any suggestions?
|
|
|
|
|
You can put together a Font object based on the control selections, and set a Label's Font property accordingly
|
|
|
|
|
what about the size and script type of the font? Do i need to include another statement before displaying on the sample display? or i can include them together with the font and style type?
|
|
|
|
|
They are included in the font style. So are bold, underline, italic, strikethrough and some other effects which I can't remember
|
|
|
|
|
Exactly what ComputaFreak Said...
You need to take a Font Object. .
Font fnt = new Font();
fnt.FontSize = 12;
fnt.Bold = true;
Anything you have in font dialog option...
And just pass the font property of textbox to the derived font.
Txtbox1.Font = fnt;
thats it. .
|
|
|
|
|
in this way, is the font size and style fixed? can the user choose from a list of values?
|
|
|
|
|
Of course...
But you may need to design the list box.. and combos and everything. .
|
|
|
|
|
okay.I will try out this method.If I still cant get it I will ask u again.
Thanx alot jaypatel512 and Computafreak! 
|
|
|
|
|
|
Sorry. I still havent gotten my thingy yet. Looks like I have to trouble you all again.
That time you said by creating a font object, I can display the values in a sample display.
I have searched the net regarding font object but there is no detailed explanation on it.
Can you show me an example so that I can understand better?
sorry for the inconvenience caused.
|
|
|
|
|
There is nothing in Font object...
First you create a Form..
Place 3 buttons. and one Rich Text Box.
now name three buttons as bold, underline, and italic.
Give some text to richtextbox. e.g.Sample Line.
Take a Font object at the topmost part of the class.
e.g. Font fnt = new Font();
Now on buttons click events... e.g. buttonbold click event write this.
fnt.Bold = !fnt.Bold; //This will invert the bold .
txtsample.Font = fnt; //This will change the text according to the font you have changed.
And see the difference in Textbox..
If this works , just make other button events as you like. .
Go step by step...
You may get it. .
|
|
|
|
|
I have just tried out the method that you suggested. But there's an error in the program.
I think I know what goes wrong and I am now figuring out the way to correct it. Thank for your suggestion. I will try to understand it and get back to you again if I still got problems.
Grateful for your help! 
|
|
|
|
|
My pleasure dude. .
You can share the error you got. .
Might be helped by someone else. .
|
|
|
|
|
hmm..okay..
one of the error said that System.Drawing.Font cannot be assigned. It is read-only. In this case, how do I assign my combo box value to get the displayed font?
|
|
|
|