1

I am working on a VSTO project and want to use Word Dialog Boxes in Hidden Mode, just like code below:

Code from MSDN

dynamic dialog = Application.Dialogs[Word.WdWordDialog.wdDialogFilePageSetup];
dialog.PageWidth = "3.3\"";
dialog.PageHeight = "6\"";
dialog.TopMargin = "0.71\"";
dialog.BottomMargin = "0.81\"";
dialog.LeftMargin = "0.66\"";
dialog.RightMargin = "0.66\"";
dialog.HeaderDistance = "0.28\"";
dialog.Orientation = "0";
dialog.DifferentFirstPage = "0";
dialog.FirstPage = "0";
dialog.OtherPages = "0";

// Apply these settings only to the current selection with this line of code:
dialog.ApplyPropsTo = "3";

// Apply the settings.
dialog.Execute(); 

I want to implement another diaglog wdDialogEditFind, but methods and properties are unknown. then use reflection to retrieve them (late binding). but no useful methods found.

Word.Dialog dlg = this.Application.Dialogs[Word.WdWordDialog.wdDialogEditFind];

System.Type t = dlg.Type.GetType();
System.Reflection.MemberInfo[] memInfo = t.GetMembers();
    
string str = "";
foreach (System.Reflection.MemberInfo m in memInfo)
    str += m.Name + "\n";
Community
  • 1
  • 1
eason
  • 53
  • 1
  • 7

1 Answers1

1

MS Word interop hides these members from you since it relies on COM RCW. Reflection cannot be used to iterate through the properties since they are not defined for the Dialog base type. If you want to know what properties are available - see this MSDN reference for built-in dialog box arguments for wdDialogEditFind.

Built-in Dialog Box Arguments for wdDialogEditFind (from MSDN)

Find, Replace, Direction, MatchCase, WholeWord, PatternMatch, SoundsLike, FindNext, ReplaceOne, ReplaceAll, Format, Wrap, FindAllWordForms, MatchByte, FuzzyFind, Destination, CorrectEnd, MatchKashida, MatchDiacritics, MatchAlefHamza, MatchControl

If you are insistent upon knowing the COM methods and properties - you can dig into IDispatch and weed your way through the COM types.

Community
  • 1
  • 1
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173