How do I change the path of the Word.WdWordDialog.wdDialogFileOpen?

  • Thread starter Ken Kee via OfficeKB.com
  • Start date
K

Ken Kee via OfficeKB.com

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.
 
C

Cindy M -WordMVP-

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 :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top