Bonjour a tous,
Decidemment je m'en sors pas avec C#, dotnet et un addin excel que je dois creer avec Visual studio 2008, VSTO 2005 et excel 2003, il s'agit bien d'un projet addin et non workbook.
Voila je recupere un objet range lorsque l'utilisateur modifie la valeur d'une cellule en recuperant l'evenement :
A chaque fois que je modifie une cellule, ma fonction Application_SheetChange est bien executer, elle se prototype de la sorte :this.Application.SheetChange += new Microsoft.Office.Interop.Excel.AppEvents_SheetChangeEventHandler(Application_SheetChange);
En revanche l'objet Range que je recupere est du type :void Application_SheetChange(object Sh, Microsoft.Office.Interop.Excel.Range Target) {}
Microsoft.Office.Interop.Excel.Range {System.Runtime.Remoting.Proxies.__TransparentProxy}
Je peux acceder a certains champs mais pas aux champs Name qui me leve une exception ...
Edit :
J'ai meme reduit le probleme a :
A la ligne : MessageBox.Show(range.Name);
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15 void Application_SheetChange(object Sh, Microsoft.Office.Interop.Excel.Range Target) { try { Excel.Workbook wb = Globals.ThisAddIn.Workbook; Excel.Worksheet ws = Globals.ThisAddIn.Worksheet; Excel.Range range = ws.get_Range("A1", "A1"); range.Name = "Block"; MessageBox.Show(range.Name); } catch (Exception notIE) { MessageBox.Show("Exception : " + notIE.Message); //throw new NotImplementedException(); } }
Exception leve :
Nom inconnu. (Exception from HRESULT; 0X80020006 (DISP_E_UNKNOWNAME))
Alors que ma cellule A1 est bien nomme block...
Merci
Partager