Application.GetOpenFilename

  • Thread starter Philipp Oberleitner
  • Start date
P

Philipp Oberleitner

Is there a possibility to give this command a directorsy he should start on
default
for example D:\Test then the user gets to see the files which are in there
first
 
N

Norman Jones

Hi Philipp,

Adapting the code from my last response in your previous thread, try:

Sub Test2()
Dim fName As Variant
ChDrive "D\"
ChDir "D:\Test"
fName = Application.GetOpenFilename
Test3 fName

End Sub

Sub Test3(Filenme)
Workbooks.Open Filenme

End Sub
 
D

Dave Peterson

Option Explicit
Sub testme()

Dim myOtherFolder As String
Dim myFileName As Variant
Dim MyCurFolder As String
Dim wkbk As Workbook

myOtherFolder = "C:\temp"
MyCurFolder = CurDir

ChDrive myOtherFolder
ChDir myOtherFolder
myFileName = Application.GetOpenFilename
ChDrive MyCurFolder
ChDir MyCurFolder

If myFileName = False Then
Exit Sub
Else
Set wkbk = Workbooks.Open(Filename:=myFileName)
End If

End Sub
 
Top