none
Detect the Styling of Word Application Dialog Popup Windows C# RRS feed

  • Question

  • I have a word addin develop using c# and wpf. It has some custom developed dialog popups which are developed using wpf xaml controls and bind in to .net form control.

    I have experienced that MS Word 2010 and MS Word 2013 inbuilt popups such as "modify Style" dialog popup styles are having little difference. And also my custom dialog popups are having my own styles in xaml window.

    My intention is to get an idea of getting style information from inbuilt dialogs from word application.

    Below mentioned code  I used for create the popup box.

    DialogForm dialogForm = new DialogForm();
    NativeWindow mainWindow = new NativeWindow();  
    mainWindow.AssignHandle(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle);
    DialogResult dialogResult = dialogForm .ShowDialog(mainWindow);
    mainWindow.ReleaseHandle();

    Thanks.
    Wednesday, July 20, 2016 3:26 PM

Answers

  • >>>From below dynamic variable I can set new property values in to windows,But I need to get default  properties of dialog box.

    According to your description, many of the built-in dialog boxes in Microsoft Word have options that you may want to set. To set or return the properties associated with a Word dialog box, use the equivalent Visual Basic properties and methods. You could refer to below code:
    dynamic dialog = Globals.ThisAddIn.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFormatDefineStylePara];
    dialog.Show();
    System.Windows.Forms.MessageBox.Show(dialog.LeftIndent);

    For more information, click here to refer about Built-in Dialog Box Argument Lists

    • Marked as answer by David_JunFeng Friday, July 29, 2016 7:03 AM
    Friday, July 22, 2016 9:54 AM

All replies

  • >>>I have experienced that MS Word 2010 and MS Word 2013 inbuilt popups such as "modify Style" dialog popup styles are having little difference. And also my custom dialog popups are having my own styles in xaml window.

    My intention is to get an idea of getting style information from inbuilt dialogs from word application.<<<

    According to your description, you could use VBA code to open built-in dialog("Modify Style"):
    Application.Dialogs(1347).Show
    Unfortunately, I am not able to find any way to open built-in dialog("Modify Style") in Word VSTO Add-in.

    You could check it throw below link:

    WdWordDialog enumeration

    How to: Programmatically Use Built-In Dialog Boxes in Word

    So I suggest that you could submit any feedback to Word UserVoice:

    https://word.uservoice.com/

    Thanks for your understanding. 
    Thursday, July 21, 2016 6:23 AM
  • Hi David,

    I apply below code to open inbuilt dialog box from code.Any how, can I access the properties such as font,background color etc from that window.

    From below dynamic variable I can set new property values in to windows,But I need to get default  properties of dialog box.

    var dialog = Globals.ThisAddIn.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFormatDefineStylePara];
    dynamic dialog = Globals.ThisAddIn.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFormatDefineStylePara];

    My intention is to get the MS Word appearance theme/styles especially in Dialog Boxes. It is not word document level properties such as paragraphs etc.

    Thanks.

    Friday, July 22, 2016 5:49 AM
  • >>>From below dynamic variable I can set new property values in to windows,But I need to get default  properties of dialog box.

    According to your description, many of the built-in dialog boxes in Microsoft Word have options that you may want to set. To set or return the properties associated with a Word dialog box, use the equivalent Visual Basic properties and methods. You could refer to below code:
    dynamic dialog = Globals.ThisAddIn.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialogFormatDefineStylePara];
    dialog.Show();
    System.Windows.Forms.MessageBox.Show(dialog.LeftIndent);

    For more information, click here to refer about Built-in Dialog Box Argument Lists

    • Marked as answer by David_JunFeng Friday, July 29, 2016 7:03 AM
    Friday, July 22, 2016 9:54 AM