Results 1 to 8 of 8
  1. #1
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010

    Open pictures in folder.


    I have a button on a form to open pictures, using the following code...

      Application.FollowHyperlink "T:\Collective Reporting\Accident Folders\" & strFYear & "\" & Me.[NRptNo] & "\01.JPG"
    This works great if I only want to open the picture named 01.
    Is there a way I can open this first picture, and be able to scroll through the rest of the pictures that are in that same folder? It used to work with the old photo viewer, but now we are using Photo Gallery, and it won't bring up the scroll arrow.

    Thank you.

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows 10 Office 365
    Join Date
    Sep 2009
    Ottawa, Ontario, Canada; West Palm Beach FL
    Review this link and examples. And this one.

    You may find more examples using Google or searching within the forum.

    Also, depending on your vba skills, you could use some variables within your code and some logic to allow for file type and/or folder name. This would be in addition to and similar to your use of strFYear.
    How do you currently supply values to strFYear?

  3. #3
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Ontario, Canada
    I'm guessing that the notion of using file dialog object is to multi select?
    Sounds like the viewer app needs to load each image you want to view so maybe the fd along with code using Dir function. Or a form button to open the next image from a list or a table of records, assuming the paths are table records.
    - "doesn't work" doesn't help. Implement changes in copies of your database.
    Iím telling everyone it's good to eat dried grapes. Itís all about raisin awareness.

  4. #4
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    I'm not completely getting it. The code in the example seems to be working to open the browser window, but when I select a folder, or path directly to the folder, it says there is nothing to show, ie no pictures in the folder.
    I believe Micron is onto something where the code doesn't specify it is looking for a JPG, or anything about Photo Gallery. And I don't know how to write that part, or where it would go.
    Here is the code I have so far...

    Private Sub ComPic_Click()On Error GoTo ProcError
     Dim strYear As String
     Dim strFYear As String
     Dim sFolder As String
     If Me.txtNMonth < 4 Then
        strYear = Me.txtNYear - 1
     Else: strYear = Me.txtNYear
     End If
     strFYear = Right(strYear, 2)
     strFYear = "FY" & strFYear
        ' Open the select folder prompt
        With Application.FileDialog(msoFileDialogFolderPicker)
            .InitialFileName = "T:\Collective Reporting\Accident Folders\" & strFYear & "\" & Me.[NRptNo]
            If .Show = -1 Then ' if OK is pressed
                sFolder = .SelectedItems(1)
            End If
        End With
        If sFolder <> "" Then ' if a file was chosen
            ' *********************
            ' put your code in here
            ' *********************
        End If
        Exit Sub
        Select Case Err.Number
            Case 490
             MsgBox "No Pictures Available"
            Case Else
                MsgBox Err.Number & ": " & Err.Description, vbCritical, _
                           "Error in cmdOK_Click Event Procedure..."
        End Select
        Resume ExitProc
    End Sub

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    The Great Land
    So need to loop through image files in folder and display in viewer. Since viewer doesn't offer 'Next' and 'Previous' navigation of images, this means opening image, viewing, closing, returning to Access, selecting next file. Annoying. Consider:

    Sub ViewImages(ByVal strFolder As String, strFileSpec As String)
        Dim strTemp As String
        Dim vFolderName As Variant
        strFolder = TrailingSlash(strFolder)
        strTemp = Dir(strFolder & strFileSpec)
        Do While strTemp <> vbNullString
            FollowHyperlink strFolder & strTemp
            If MsgBox("Continue?", vbYesNo) = vbYes Then
                strTemp = Dir
                Exit Do
            End If
    End Sub
    Call that code like: ViewImages "C:\Users\Owner\June\MyStuff", "*.jpg"

    Could load image file names from folder to a listbox and user clicks through listbox.

    Or view images on form with Image control where you can do navigation.
    How to attach file: To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    Join Date
    Jan 2017
    Swansea,South Wales,UK
    You are using FolderPicker?

    You should be using FilePicker surely?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting:
    Debugging Access:

  7. #7
    isladogs's Avatar
    isladogs is offline Very idle programmer
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Somerset, UK
    Colin (Mendip Data Systems): Website, email
    Try again. Fail again. Fail better.
    sking for help isn't giving up. Its refusing to give up.

  8. #8
    NISMOJim is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jul 2010
    I've never used this code before, so I never would have caught it. But Welshgasman was right on. Changing FolderPicker to FilePicker did the trick. It doesn't open the picture, but opens the correct folder to the pictures, and when opened, I can scroll through the pictures in that folder again. This may be a better option, since other users may have a different picture viewing program that they use.
    Thank you all for your help.

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

Similar Threads

  1. Replies: 3
    Last Post: 10-13-2015, 10:21 AM
  2. Replies: 10
    Last Post: 09-09-2015, 03:25 AM
  3. open folder/Make new folder(example)-VBA Code
    By Madmax in forum Code Repository
    Replies: 3
    Last Post: 03-13-2012, 09:17 AM
  4. Replies: 11
    Last Post: 10-01-2010, 11:12 PM
  5. Enter a folder name and open that folder
    By pkstormy in forum Code Repository
    Replies: 0
    Last Post: 09-05-2010, 04:39 PM

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