Solved

ms/access 2013 open external file

Posted on 2015-02-04
3
585 Views
Last Modified: 2016-02-11
I need to open an external file in MS/ACCESS 2013. The user needs to brows on the computer, opened the file (a standard ms/office file e.g. word, excel, ppt) or a PDF / picture and, upon selection, I need to change its name and store in a common folder, albeit keeping its extension for further opening.
Ideally this should be embedded in a control, but its OK to open on a separate window, as long as I get the full path for the file to store it on a database record.
how do I do it?
0
Comment
Question by:jirdeaid
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 48

Assisted Solution

by:Dale Fye (Access MVP)
Dale Fye (Access MVP) earned 250 total points
ID: 40588892
I use the following function to browse and select a file name.  The function arguments provide a method for changing the title of the box, identifying specific file types, and identifying whether to allow selection of one or more files.

Public Function GetFile(Optional Title As String = "", _
                        Optional DefaultPath As String = "C:\", _
                        Optional FileTypes As String, _
                        Optional MultiSelect As Boolean = False) As String

    Dim fd As Object
    Dim strFileTypes() As String, intLoop As Integer
    
    Set fd = FileDialog(3)  'msoFileDialogFilePicker
    With fd
    
        .Title = IIf(Title = "", "Select a file", Title)
       ' .RestoreDirectory = False

        'Allow for multiple filetypes in the FileTypes string
        strFileTypes = Split(FileTypes, ";")
        For intLoop = LBound(strFileTypes) To UBound(strFileTypes)
            If Trim(strFileTypes(intLoop)) = "Access" Then
                .Filters.Add "Microsoft Access", "*.mdb;*.mda;*.mde;*.accdb;*.accda;*.accde"
            ElseIf Trim(strFileTypes(intLoop)) = "Excel" Then
                .Filters.Add "Microsoft Excel", "*.xl*;*.xls*"
            ElseIf Trim(strFileTypes(intLoop)) = "Text" Then
                .Filters.Add "Text", "*.txt;*.csv"
            End If
        Next
        
        'If no file type is designated, use *.*
        If UBound(strFileTypes) = -1 Then .Filters.Add "Any file type", "*.*"
        
        .AllowMultiSelect = MultiSelect
        .InitialView = 2        'msoFileDialogViewDetails
        
        'Display the popup and process the return
        If .Show = 0 Then
            GetFile = ""
        Else
            For intLoop = 1 To .SelectedItems.Count
                If GetFile = "" Then
                    GetFile = .SelectedItems(intLoop)
                Else
                    GetFile = GetFile & ";" & .SelectedItems(intLoop)
                End If
            Next
        End If
    End With
    
    Set fd = Nothing
        
End Function

Open in new window

0
 
LVL 38

Accepted Solution

by:
PatHartman earned 250 total points
ID: 40588916
Here's a link to the MSOFileDialogFilePicker.  It is supported as early as A2003.  There are also other options such as MSOFileDialogFolderPicker when you want just a folder.

https://msdn.microsoft.com/en-us/library/office/aa195878(v=office.11).aspx

Save the full filename selected using the dialog in your table.  Use the FollowHyperlink method to open the file.

https://msdn.microsoft.com/en-us/library/office/ff822080(v=office.15).aspx

Using the FollowHyperlink method will allow Access to open ANY file type that is defined to windows so that it knows what program to open.  So essentially, if you can double-click on the file in Windows Explorer and have the correct program open, then FollowHyperlink will do the same thing.  This method also allows you to open web pages and your email client.
0
 

Author Closing Comment

by:jirdeaid
ID: 40590558
Thanks a lot for both! (and for the very prompt answer. As a matter of fact I am using Dale's function and Pat's followlink....
0

Featured Post

[Webinar] Learn How Hackers Steal Your Credentials

Do You Know How Hackers Steal Your Credentials? Join us and Skyport Systems to learn how hackers steal your credentials and why Active Directory must be secure to stop them. Thursday, July 13, 2017 10:00 A.M. PDT

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

695 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question