Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

default to server forder

Status
Not open for further replies.

Johnny42

Technical User
Jul 13, 2004
127
CA
can the Application.GetOpenFilename be defaulted to a folder on my server ?
this doe not work....
Code:
Dim sFname As String
ChDir "\\Srvsho01\Afwdata\DataImp"
  
    sFname = Application.GetOpenFilename( _
        FileFilter:="Excel Workbooks,*.xls", _
        Title:="Open a File", _
        MultiSelect:=False)
    
    If sFname <> "False" Then
        Workbooks.Open sFname
    End If
 
You may try something like this:
Code:
Dim fd As FileDialog
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
    .InitialFileName = "\\Srvsho01\Afwdata\DataImp"
    .AllowMultiSelect = False
    .Filters.Add "Excel Workbooks", "*.xls", 1
    If .Show Then
        Workbooks.Open .SelectedItems(1)
    End If
End With
Set fd = Nothing
You have to reference the Microsoft Office Object Library

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
If you use a version < 2002 then you will need to resort to API's to do this.

Ivan F Moala
xcelsmall.bmp
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top