none
Integrating Word with Winforms - Dialog.Display() return values RRS feed

  • Question

  • Hey there,

    I'm attempting to integrate Word's spell checking functionality into a WinForms app.  Here's the relevant code:

    oWordServer.Visible = True
    oWordServer.Activate()
    iResp = oWordServer.Dialogs(Word.WdWordDialog.wdDialogToolsSpellingAndGrammar).Display()

    Where oWordServer is an instance of Microsoft.Office.Interop.Word.Application.  Based on the information on the MSDN site,  it's my understanding that this should return different values into the iResp variable if the "Change" button and "Cancel" Button are clicked, because I'd like to perform different operations in each scenario.  However, both buttons cause the function to return a value of -1.  Can anyone help me understand why this is? Or point me in a better direction?

    Thanks!

    Kyle

    • Moved by Barry Wang Friday, June 6, 2014 8:41 AM
    Thursday, June 5, 2014 4:33 PM

All replies

  • Hi,

    We have moved this thread to more related forum to get dedicated supports.

    Thanks for your understanding.

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 6, 2014 8:43 AM
  • I can reproduce this issue too. From my investigation, except pressing cancle button it will return 0(right return value) .

    • Edited by BruseBoBo Tuesday, June 10, 2014 9:41 AM
    Friday, June 6, 2014 9:40 AM
  • Thank you! Also, when I initialize the instance of Word I use this code:

    oWordServer = DirectCast(GetObjet(, "Word.Application"), Word.Application)

    or

    oWordServer = DirectCast(CreateObject("Word.Application"), Word.Application)
    Depending on whether there's already an instance of Word running

    Not sure if this is something that would cause this to behave differently, but thought it might be helpful if you're trying to reproduce it

    Friday, June 6, 2014 1:18 PM
  • Hi,

    I'm trying to involve some senior engineers into this issue and it will take some time. Your patience will be greatly appreciated.

    Sorry for any inconvenience and have a nice day!

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, June 13, 2014 9:45 AM
    Moderator
  • Hi,

    I use the below code:

    private void button1_Click(object sender, EventArgs e)
    {
                Word.Application wApp = new Word.Application();
                Word.Document doc = wApp.Documents.Add();
                doc.Range().Text = "Hello Wolrd";
                int iResp = wApp.Dialogs[Word.WdWordDialog.wdDialogToolsSpellingAndGrammar].Display();
                System.Windows.Forms.MessageBox.Show(iResp.ToString());
    }

    I get "0" if dialog was closed by clicking "Cancel" button and get "-1" if the dialog gets closed after clicking the "Change" button.

    Can you share your minimal code snippet with which you can reproduce the issue?

    -Ajay

    Friday, June 27, 2014 3:10 PM