open folder/document cmd

  • Thread starter Thread starter destrang
  • Start date Start date
D

destrang

Guest
I need some shortcut buttons in my form for opening folders and/or certain documents. I have tried to create a macro but there is nothing that supports opening a folder or other documents such as PDF.

Any ideas?

Thanks, De :confused:
 
destrang said:
I need some shortcut buttons in my form for opening folders and/or certain documents. I have tried to create a macro but there is nothing that supports opening a folder or other documents such as PDF.

Any ideas?

Thanks, De :confused:

Hi You can open a document, but I do not know how to open a folder, I would like to do this also.

Use the Run app macro in the comand line type something like:
j:\MSOFFICE\OFFICE\EXCEL.EXE "c:\mydocuments\rota.xls"

This calls the program first from the directory it is installed, then call the file you want opening after it.

You can then tie the macro to the button on the form.

Hope this helps

Mike
 
Last edited:
open doc button

That part did work fine, thanks.

I am still trying to find a way to "browse a folder".

Thanks for your help

De
 
Hi. Is it possible to store the content of a selected folder (your Open Common Dialog Box example) in some temp table in Access database?
Thank you.
Alika
 
Last edited:
Create a table called tblFileNames with one memo field called "File". Place the following code in the OnClick event of a button changing the file extension (in red) to the files you want listed (this looks for excel files) and the folder (in blue) to the folder you want to look in.
Code:
DoCmd.RunSQL "DELETE tblFileNames.File FROM tblFileNames;"
Set rstFiles = CurrentDb.OpenRecordset("tblFileNames", dbOpenDynaset)
    With Application.FileSearch
        .NewSearch
        .LookIn = "[color=blue]c:\[/color]"
        .SearchSubFolders = True
        .FileName = ""
        .MatchAllWordForms = True
            If .Execute() > 0 Then
                For i = 1 To .FoundFiles.Count
                    If Right(.FoundFiles(i), 3) = "[color=red]xls[/color]" Then
                        rstFiles.AddNew
                        rstFiles("File") = .FoundFiles(i)
                        rstFiles.Update
                    End If
                Next i
            Else
                MsgBox "No files found."
            End If
    End With

rstFiles.Close
Not forgetting to set a reference to Microsoft DAO Object Library.

If you want to view all file types in the folder, use the following.
Code:
DoCmd.RunSQL "DELETE tblFileNames.File FROM tblFileNames;"
Set rstFiles = CurrentDb.OpenRecordset("tblFileNames", dbOpenDynaset)
    With Application.FileSearch
        .NewSearch
        .LookIn = "[color=blue]c:\[/color]"
        .SearchSubFolders = True
        .FileName = ""
        .FileType = msoFileTypeAllFiles
        .MatchAllWordForms = True
            If .Execute() > 0 Then
                For i = 1 To .FoundFiles.Count
                     rstFiles.AddNew
                     rstFiles("File") = .FoundFiles(i)
                     rstFiles.Update
                Next i
            Else
                MsgBox "No files found."
            End If
    End With

rstFiles.Close
HTH
 
Last edited:
___ said:
Create a table called tblFileNames with one memo field called "File". [/code]
HTH

Many thanks! It works!
Alika
 

Users who are viewing this thread

Back
Top Bottom