2017-12-14 4 views
0

/こんにちは、2010年のvstoアドインを作成しています。このアドインにはボタンがあり、クリックすると新しいフォームが開きますユーザーの入力(テキストボックスとラベルとボタンの組み合わせを使用)。理論は、私が[OK]ボタンをクリックすると、プログラムはテキストボックステキストを取り、vstoアドインリボンクラスで見つかったメソッドを呼び出します。何らかの理由で(これは単純な間違いかもしれませんが、どこが間違っているのか分かりません)、OKボタンを使ってメソッドを呼び出すことができません。次は、コードの一部です/新しいフォームからvsto単語リボンで作成されたメソッドにアクセスする方法

// RIBBON FOR CODE

namespace somenamespace 
{ 
public partial class Ribbon1 
{ 
    private void Ribbon1_Load(object sender, RibbonUIEventArgs e) 
    { 

    } 

    private void button1_Click(object sender, RibbonControlEventArgs e) 
    { 
     Word.Document document = Globals.ThisAddIn.Application.ActiveDocument; }   

//This method is used to replace the generic text with the one that we need 
    //specifically for our document 

    public void MyMethod(string TextToReplace, string NewText) 
    { 
     Word.Find fnd = Globals.ThisAddIn.Application.Selection.Find; 

     fnd.ClearFormatting(); 
     fnd.Replacement.ClearFormatting(); 
     fnd.Forward = true; 
     fnd.Wrap = Word.WdFindWrap.wdFindContinue; 

     fnd.Text = TextToReplace; 
     fnd.Replacement.Text = NewText; 

     fnd.Execute(Replace: Word.WdReplace.wdReplaceAll); 
    } 

    private void buttonScopingApproval_Click(object sender, RibbonControlEventArgs e) 
    { 

     Info_Scoping info_Scoping = new Info_Scoping(); 
     info_Scoping.Show(); 
    } 
} 

// Info_Scopingは、ユーザの入力を表示します新しいWPFフォームの名前であり、これはのためのコードですそれ:

namespace moeRibbon 
{ 
public partial class Info_Scoping : Form 
{ 
    public Info_Scoping() 
    { 
     InitializeComponent(); 
    } 


    public void buttonOK_Click(object sender, EventArgs e) 
    { 
     Info_Scoping.ActiveForm.Hide(); 
     RegNumber = textBox1.Text; 
     RegYear = textBox2.Text; 
     //I need to access the MyMethod() method created in the ribbon class from here, but intellisense doesn't recognize it.   


    } 

    public string RegNumber { get; set; } 
    public string RegYear { get; set; }  

} 
} 

答えて

0

私はあなたが探しているものと信じている:

Globals.Ribbons.Ribbon1.MyMethod(string, string); 
+0

おかげでたくさん!作品 – Ali

関連する問題