Bonjour,
J'essaie d'enrichir automatiquement le volet suivant:
avec les données qui se trouvent dans la feuille 3 du classeur plage ("C15:C22")
J'essaie d'adapter le code VB suivant:
qui fonctionne.
Ma conversion à partir de la ligne 31:
Mon erreur:
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
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43 using Microsoft.Office.Interop.Excel; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; using Office = Microsoft.Office.Core; namespace ExcelWorkbook1 { partial class ActionsPaneControl1 : UserControl { public ActionsPaneControl1() { InitializeComponent(); } /*private void button1_Click(object sender, EventArgs e) { MessageBox.Show("Opération terminée"); }*/ private void ActionsPaneControl1_Load(object sender, EventArgs e) { tabControl1.Appearance = TabAppearance.FlatButtons; tabControl1.ItemSize = new System.Drawing.Size(0, 1); tabControl1.SizeMode = TabSizeMode.Fixed; SetDefault(); } private bool SetDefault() { Control myCtrlT; foreach (Range rng in (Range) Globals.ThisWorkbook.Worksheets[3].Range("C15:C22")) { myCtrlT = Controls.Find(rng.Value, true).FirstOrDefault(); myCtrlT.Text = rng.Value.Offset(0, 1); myCtrlT.ForeColor = System.Drawing.Color.Gray; } return true; }
Pouvez vous SVP m'apporter une solution?
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
16
17
18
19 ************** Texte de l'exception ************** System.ArgumentNullException: La clé spécifiée était vide ou avait une valeur null. Nom du paramètre*: key à System.Windows.Forms.Control.ControlCollection.Find(String key, Boolean searchAllChildren) à System.Dynamic.UpdateDelegates.UpdateAndExecute3[T0,T1,T2,TRet](CallSite site, T0 arg0, T1 arg1, T2 arg2) à ExcelWorkbook1.ActionsPaneControl1.SetDefault() dans C:\Users\ericm\source\repos\ExcelWorkbook1\ExcelWorkbook1\ActionsPaneControl1.cs:ligne 37 à ExcelWorkbook1.ActionsPaneControl1.ActionsPaneControl1_Load(Object sender, EventArgs e) dans C:\Users\ericm\source\repos\ExcelWorkbook1\ExcelWorkbook1\ActionsPaneControl1.cs:ligne 30 à System.Windows.Forms.UserControl.OnLoad(EventArgs e) à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) à System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible) à System.Windows.Forms.Control.CreateControl() à System.Windows.Forms.Control.SetVisibleCore(Boolean value) à Microsoft.Office.Tools.ActionsPaneInternal.SetVisibleCore(Boolean visible) à Microsoft.Office.Tools.DockableControlCollection.Add(Control value) à ExcelWorkbook1.ThisWorkbook.ThisWorkbook_Startup(Object sender, EventArgs e) dans C:\Users\ericm\source\repos\ExcelWorkbook1\ExcelWorkbook1\ThisWorkbook.cs:ligne 9 à Microsoft.Office.Tools.Excel.WorkbookImpl.OnStartup() à ExcelWorkbook1.ThisWorkbook.FinishInitialization() dans C:\Users\ericm\source\repos\ExcelWorkbook1\ExcelWorkbook1\ThisWorkbook.Designer.cs:ligne 62 à Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.ExecutePhase(ExecutionPhases executionPhases) à Microsoft.VisualStudio.Tools.Office.Runtime.DomainCreator.ExecuteCustomization.Microsoft.VisualStudio.Tools.Office.Runtime.Interop.IExecuteCustomization2.ExecuteEntryPoints()
Merci
Eric
Partager