I want to be able to change the file path from the default "My documuent"
path to something like "e:\test\doc\", see the codes below:

private void WordDialog()
{
object m = Type.Missing;
Word.Dialog dlg =
thisApplication.Dialogs
[Word.WdWordDialog.wdDialogFileOpen];
Type dlgType = typeof(Word.Dialog);
string path = selectedServerPath;

// Set name property of dialog box.
dlgType.InvokeMember("Name",
System.Reflection.BindingFlags.SetProperty |
System.Reflection.BindingFlags.Public |
System.Reflection.BindingFlags.Instance,
null, dlg, new object[] {"e:\\test\\doc\\*.doc"});

// Display dialog box.
dlg.Show(ref m);

Close();
}

The code still gives me the "My documuent" path, when this method is
called. How can I fix it? Thanks.

--
Message posted via http://www.officekb.com

Re: How do I change the path of the Word.WdWordDialog.wdDialogFileOpen? by Cindy

Cindy
Sun Apr 24 05:56:03 CDT 2005

Hi Ken,

I'm not sure you're going to be able to, via C#. Usually, we have to put a
SendKeys just in front of the line invoking the .Show method of the Dialog
to change the pre-selected path in this dialog box.

Might make more sense to use the FileDialog object, instead of the built-in
dialog.

> I want to be able to change the file path from the default "My documuent"
> path to something like "e:\test\doc\", see the codes below:
>
> private void WordDialog()
> {
> object m = Type.Missing;
> Word.Dialog dlg =
> thisApplication.Dialogs
> [Word.WdWordDialog.wdDialogFileOpen];
> Type dlgType = typeof(Word.Dialog);
> string path = selectedServerPath;
>
> // Set name property of dialog box.
> dlgType.InvokeMember("Name",
> System.Reflection.BindingFlags.SetProperty |
> System.Reflection.BindingFlags.Public |
> System.Reflection.BindingFlags.Instance,
> null, dlg, new object[] {"e:\\test\\doc\\*.doc"});
>
> // Display dialog box.
> dlg.Show(ref m);
>
> Close();
> }
>
> The code still gives me the "My documuent" path, when this method is
> called. How can I fix it? Thanks.
>

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
http://www.word.mvps.org

This reply is posted in the Newsgroup; please post any follow question or
reply in the newsgroup and not by e-mail :-)