Results 1 to 2 of 2
  1. #1
    dnelms is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    1

    Button to Open a Specific Folder

    Access 2007... added a button that when pressed opens MS Word and takes the user to a specific folder to open a Word document.



    Within the company I work for, operators fill out incident reports in Word and then the next shift will put those reports into a database. So on the form I've added a button that will open MS Word, but I can't get it to then open the Word dialog box to a certain folder.

    Here is my code:
    Private Sub cmdbtnOpenWord_Click()
    Dim retVal, strPathToWord As String, strDir As String
    strPathToWord = "C:\Program Files\Microsoft Office\Office12\winword.exe "
    strPathToDir = "S:\ICS Computer Operations\ICS Incident Reports\2011\*.doc"

    retVal = Shell(strPathToWord & strPathToDir, vbMaximizedFocus)

    End Sub

    It opens Word just fine, but then will not open the dialog box for Word. Anyway to do this or should I be content with it just opening Word for me? The operator still will have to choose the correct file they wish to open.

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I'd probably come at it a different way. You're opening Word and then trying to find a file. I'd probably get the file and then open it in Word. Two options that come to mind are just opening Windows Explorer to your directory (FollowHyperlink) and letting the user double click on the desired file, or use File Dialog to get the desired file name, then opening it (FollowHyperlink or Shell).
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Button to open on specific Data
    By glasgowlad1999 in forum Access
    Replies: 6
    Last Post: 05-15-2011, 03:46 PM
  2. Replies: 5
    Last Post: 03-03-2011, 03:56 PM
  3. Enter a folder name and open that folder
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 09-05-2010, 04:39 PM
  4. Replies: 3
    Last Post: 01-14-2010, 08:32 AM
  5. Replies: 0
    Last Post: 12-16-2009, 09:28 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums