|
|
||||||
|
#1
|
|
|
|
|
How do I find out what the arguments/members of a given Word.Dialog are?
I can invoke them fine using the code from: http://msdn.microsoft.com/en-us/library/ahzbkf8e, and I can get some information on member names from "Built-in Dialog Box Argument Lists" in the VBA help and from: http://word.mvps.org/faqs/macrosvba/WordDlgHelp.htm But, as stated in the Word mvp article, "Microsoft listed the arguments you can use but forgot to mention what the arguments mean or what values they can take!" Is there a way to get more information from somewhere, or to return the argument lists of a specific dialog with reflection? I'm tring to invoke specific dialogs with various properties 'preset' for the user... Thanks, Tobek |
|
|
|
#2
|
|
|
|
|
Hi Tobek,
You wrote: > How do I find out what the arguments/members of a given Word.Dialog are? > Is there a way to get more information from somewhere, or to return the > argument lists of a specific dialog with reflection? I'm tring to invoke > specific dialogs with various properties 'preset' for the user... I don't think there is any hope of finding better documentation than what they have in the VBA docs for the built-in dialog objects. VSTO documentation states the following about the Dialog type: "Interactions with built-in Word dialog boxes are through late binding, so if you have Option Strict set to On or you use C#, you cannot access members of the dialog boxes directly. You must use the Reflection libraries to access dialog box members." So, in C# you can't even access the properties of the Dialog object directly. You can use Reflection in order to get all the members exposed by an object of type Microsoft.Office.Interop.Excel.Dialog. You can paste the following code inside the ThisDocument class Startup / Open eventhandler (in a VSTO Beta1 Word document project). // Get an built-in Word dialog box. Word.Dialog dlg = this.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialo gEditFind]; // Get all the members exposed by the built-in dialog. System.Type t = dlg.Type.GetType(); System.Reflection.MemberInfo[] memInfo = t.GetMembers(); // Display a list of the names of each member in a MessageBox. string str = ""; foreach (System.Reflection.MemberInfo m in memInfo) str += m.Name + "\n"; MessageBox.Show(str); You can also use Reflection to invoke a member method or get/set a property on a Dialog object. Hope this helps, Apurva Sinha VSTO Customer Solutions |
|
#3
|
|
|
|
|
Thanks for the reply, Apurva. I suspected that that would be the case.
As Paul Vick said in a recent blog post (http://www.panopticoncentral.net/arc...2/10/7574.aspx), I'm not masochistic enough to want to program VSTO in C# :-) So, I'll have some fun translating your code to Vb.Net. Though I think I've already tried this, and just got a list of the same methods of a dialog that I saw in the object browser... I'm sure that Microsoft must have internal documentation of the properties of Word/Excel dialogs. Is there some reason why this cannot be made available to Office developers? Tobek "Apurva Sinha (MS)" wrote: [..] |
|
#4
|
|
|
|
|
Hi Tobek,
You wrote: > Though I think I've already tried this, and > just got a list of the same methods of a dialog that I saw in the object > browser... If you reflect on the object that is returned by indexing into the dialogs collection, then you will see all the members exposed by that specific dialog object. You can do this in VB or C# by calling GetType() method on any object. Please look the code example below: 1. The following lines will get you a list of all the members exposed by the specific type of Dialog (the EditFind Dialog in this case): Word.Dialog dlg = this.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialo gEditFind]; System.Type t = dlg.Type.GetType(); System.Reflection.MemberInfo[] memInfo = t.GetMembers(); 2. The following lines of code will only return the members exposed by the Dialog class, as listed in the documentation you mention: Word.Dialog dlg = this.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialo gEditFind]; System.Type t = typeof (Word.Dialog); System.Reflection.MemberInfo[] memInfo = t.GetMembers(); You wrote: > I'm sure that Microsoft must have internal documentation of the properties > of Word/Excel dialogs. Is there some reason why this cannot be made > available > to Office developers? Even I don't know the answer to that question! Maybe someone more knowledgable than me can enlighten us in this regard. I suggest posting this question on an Office newsgroup with your specific example of the lack of documentation. As far as programming Office solutions in C# is concerned, I was used to C/C++ programming. For me programming in VB.NET would be masochistic :-) The great thing is that VSTO (well .NET really) gives you the choice. Apurva Sinha VSTO Customer Solutions |
|
#5
|
|
|
|
|
Thanks for the clarification, but I'm still not quite there. Using your code
in number 1 (in C# for VSTO - <gasp>): > 1. The following lines will get you a list of all the members exposed by the > specific type of Dialog (the EditFind Dialog in this case): > > Word.Dialog dlg = > this.Application.Dialogs[Microsoft.Office.Interop.Word.WdWordDialog.wdDialo gEditFind]; > System.Type t = dlg.Type.GetType(); > System.Reflection.MemberInfo[] memInfo = t.GetMembers(); I get a list of all of the different kinds of dialog boxes there are, i.e. all the members of the Microsoft.Office.Interop.Word.WdWordDialog enumeration. What I was hoping to get was the members/arguments of the specific dialog passed to the instance variable 'dlg'. In this case (wdEditFind), this should be a member list like: "Find, Replace, Direction, MatchCase, WholeWord, PatternMatch, SoundsLike, FindNext, ReplaceOne, ReplaceAll, Format, Wrap, FindAllWordForms, MatchByte, FuzzyFind, Destination, CorrectEnd, MatchKashida, MatchDiacritics, MatchAlefHamza, MatchControl" I got the above argument list from the VBA help file, as previously mentioned. The main problem with that list of course is that the type of each of these arguments is not given - although for many of them you can guess by messing with the dialog itself in Word. I'll see what response I get asking for this documentation over on one of the Word VBA lists. Thanks for your help, Tobek |
|
|
| Similar Threads | |
| Thread | Thread Starter |
| How to access built-in dialog boxes How do you find the numeric value of a built-in dialog box, such as: Dialogs(1347).Show to display the Modify Style dialog box? I am interested in accessing the Fill... |
kc |
| How to find names for built-in dialog boxes Is the list that comes up in the VB Editor as you type Dialogs( the full list available? In particular, I'm trying to find out how to call the "Modify Style"... |
Michael Eyestone |
| Built-in Dialog Boxes Is there anyway you can display dialog boxes using VBA. For example, would like to display the Save As dialog box, if a presentation has no already been saved, just before... |
Lynn Taylor |
| Customizing Word Built-In Dialog Boxes I am showing the Insert Table of Contents dialog box using VBA. "Dialogs(wdDialogsInsertTableofContents).Show" When i do this, the Show Levels box has a 9 in it. How can I... |
Lynn Taylor |
| Re : Making use of the Built-in Dialog Boxes 1. Please examine the following code :- Dim TextFind As String Call Application.Dialogs(xlDialogFormulaFind).Show(TextFind, 2, 2, 1, 0, True, True) MsgBox "TextFind = " &... |
TKT-Tang |
|
Privacy Policy | All times are GMT. The time now is 03:40 PM.
|
|
|