Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / April 2006

Tip: Looking for answers? Try searching our database.

Problem with display a  Dialog & ascertain what user pressed

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Poodle - 22 Apr 2006 18:20 GMT
Hi there

I have found that the ChangeFileOpenDirectory command in 2003 is unreliable,
although I have only found one post from someone else about this.  Anyway, in
order to display the File Open dialog screen at a particular path, I write
the (which I successfully collect from another part of the code) as a string
in a text file.  I then collect that path (Folder_Path) and use it in my file
open command as shown below.  This all works fine in various places in the
code.

In one place I need to know whether the user pressed Open of Cancel.  I
believe I need to display, rather than show, the dialog in order to get the
result.  

If I use the following code, it does not open at the correct place:

With Dialogs(wdDialogFileOpen)
   .name = Folder_Path & "\"
   .Format = wdFormatDocument
End With

Result  = Dialogs(wdDialogFileOpen).Display

However, if I use the following code it does work but then I can't get the
result back.

With Dialogs(wdDialogFileOpen)
   .name = Folder_Path & "\"
   .Format = wdFormatDocument
   .Display
End With

Can anyone tell me what I am doing wrong, please?  Or if there is another way
to get the result back?  

Any & all help greatly appreciated.

Many thanks.
Jay Freedman - 22 Apr 2006 22:08 GMT
All you're missing is assigning the return value of the .Display
method to the Result variable. Try it this way:

With Dialogs(wdDialogFileOpen)
   .name = Folder_Path & "\"
   .Format = wdFormatDocument
   Result = .Display
End With

You should have a look at
http://www.word.mvps.org/FAQs/MacrosVBA/WordDlgHelp.htm and the other
articles linked from it.

By the way, I don't understand your reference to a text file... why
not just assign the path to a variable?

--
Regards,
Jay Freedman
Microsoft Word MVP        FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

>Hi there
>
[quoted text clipped - 34 lines]
>
>Many thanks.
debbieprobert - 23 Apr 2006 08:01 GMT
Thank you so much for that.  Has worked a treat. I don't understand why it
wouldn't work outside the With statement, although I appreciate that's not as
neat any way.  Perhaps it's just that life is too short to worry about
undertstanding something if you can make it work another way :-)

You are right about the variable.  Writing the information to a text file
came about when I had problems with ChangeFileOpenDirectory and was trying to
break the process down to find out why.  The code had been working
satisfactorily in various versions of Office for many years until 2003 came
along.  Writing the information away was just to prove to myself that the
code really had 'registered' the path that I wanted.   I can put it back to
being a variable now.

Once again, thanks for your help which is hugely appreciated.

>All you're missing is assigning the return value of the .Display
>method to the Result variable. Try it this way:
[quoted text clipped - 24 lines]
>>
>>Many thanks.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.