Application.GetOpenFilename

  • Thread starter Thread starter Philipp Oberleitner
  • Start date 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
 
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
 
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top