Results 1 to 4 of 4
  1. #1
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919

    Browse for an attachment

    I have an app where I'm using CDO to configure and send emails. Included is the option to attach a file, but I've not discovered how to obtain the path of a selected file via Explorer. Is there an interface to Explorer using Shell to get the path of a selected file?

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,784
    I believe the .SelectedItems property returns a path string?

    You're not stuck with some problem here, right? Why not Google such a question? Or are you at work and are prevented from using Google or any other search engine?
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,523
    usage with a startup folder:
    Code:
    vRet = UserPick1File( "c:" )
    if vRet <> "" then txtBox = vRet


    paste code below into a module:
    Code:
    Public Function UserPick1File(byval pvPath)     'ByVal pvFilter, Optional pvPath)
    Dim strTable As String
    Dim strFilePath As String
    Dim sDialogMsg As String, sDecr  As String, sExt As String
    Const msoFileDialogFilePicker = 3
    Const msoFileDialogViewList = 1
    'Application.FileDialog(msoFileDialogSaveAs) =2     'SAVE AS
    'Application.FileDialog(msoFileDialogFilePicker) =3  'file OPEN
    
    With Application.FileDialog(3) 
        .AllowMultiSelect = True
        .Title = sDialogMsg   ' "Locate a file to Import"
        .ButtonName = "Import"
        .Filters.Clear
        '.Filters.Add sDecr, sExt
            '.Filters.Add "Access Files", "*.accdb;*.mdb"
            '.Filters.Add "Excel Files", "*.xlsx"
        .Filters.Add "All Files", "*.*"
        .InitialFileName = pvPath
        .InitialView = msoFileDialogViewList    'msoFileDialogViewThumbnail
            If .show = 0 Then
               'There is a problem
               Exit Function
            End If
        'Save the first file selected
        UserPick1File = Trim(.SelectedItems(1))
    End With
    End Function

  4. #4
    GraeagleBill's Avatar
    GraeagleBill is offline Experienced Old Geezer
    Windows 10 Access 2013 32bit
    Join Date
    Feb 2011
    Posts
    1,919
    Thanks Ranman, your code will teach me what I need to learn about FileDialog object
    Bill

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

Similar Threads

  1. Replies: 2
    Last Post: 06-28-2020, 07:57 AM
  2. Replies: 3
    Last Post: 10-13-2014, 05:48 PM
  3. Replies: 1
    Last Post: 09-04-2014, 11:10 AM
  4. Replies: 13
    Last Post: 12-05-2013, 06:04 PM
  5. Replies: 16
    Last Post: 04-30-2012, 07:12 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