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 / June 2007

Tip: Looking for answers? Try searching our database.

File Open

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ricki Miles - 27 Jun 2007 18:17 GMT
I am using Word 2003 and would like to create a macro that goes to File,
Open and navigates to a certain folder.  Once it gets to that folder, the
macro stops.  I know I am missing the last line of code to accomplish this.

TIA,

Ricki
Jay Freedman - 28 Jun 2007 01:16 GMT
>I am using Word 2003 and would like to create a macro that goes to File,
>Open and navigates to a certain folder.  Once it gets to that folder, the
[quoted text clipped - 3 lines]
>
>Ricki

You're thinking in terms of what you would do if you were operating
Word with the keyboard and mouse. VBA doesn't work that way.

The VBA way is to create an object that represents the dialog, then
set its properties so it will do what you want, and finally start it
running. In this case, the property of interest is called .Name, and
it represents the contents of the Filename box in the dialog. If you
set that property to the complete folder path and end it with a
backslash instead of a filename, the dialog will immediately open with
that folder visible:

Sub demo()
   Dim dlg As Dialog
   Set dlg = Dialogs(wdDialogFileOpen)
   
   With dlg
       .Name = "C:\Some folder\Some subfolder\"
       .Show
   End With
End Sub

--
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.
Ricki Miles - 28 Jun 2007 01:36 GMT
Thanks for your help, Jay - it works perfectly now,

Ricki

>>I am using Word 2003 and would like to create a macro that goes to File,
>>Open and navigates to a certain folder.  Once it gets to that folder, the
[quoted text clipped - 32 lines]
> Email cannot be acknowledged; please post all follow-ups to the
> newsgroup so all may benefit.
 
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.