Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

ms/access 2013 open external file

Posted on 2015-02-04
3
Medium Priority
?
634 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:João serras-pereira
[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
Dale Fye earned 1000 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 39

Accepted Solution

by:
PatHartman earned 1000 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:João serras-pereira
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Access custom database properties are useful for storing miscellaneous bits of information in a format that persists through database closing and reopening.  This article shows how to create and use them.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
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: …

609 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