Problem with the path selected by [.FileDialog(msoFileDialogFolderPicker).Show]

lookingforK

Registered User.
Local time
Today, 12:37
Joined
Aug 29, 2012
Messages
48
Hi,

I am using the following code to use Template.xlsx file that is under the path "C:\App":

Code:
Application.FileDialog(msoFileDialogFolderPicker).Show
 
strReportPath = CurDir ()
 
Set wkbDest = xl.Workbooks.Open(strReportPath & "\Template.xlsx")

But, I got error message, i.e.:
After I select the path "C:\App" in the popup folder picker dialog box, there is always an error message like: "C:\Template.xlsx cannot be found. Check your spelling, or try a different path.".

What's wrong?
Why I select "C:\App" but get "C:\" error? :banghead:

Thank you inadvance.
 
Last edited:
The problem is using CurDir. You don't need it.

Just use

Code:
Dim fldg As FileDialog
 
Set fldg = Application.FileDialog(msoFileDialogFolderPicker)
 
fldg.Show
strReportPath = fldg.SelectedItems(1)
 
Last edited:
CurDir() returns normally the default Folder.. Try creating a FileDialog Object and take it from there.. something like..
Code:
    Dim fileDump As FileDialog
    Set fileDump = Application.FileDialog(msoFileDialogFolderPicker)
    fileDump.Show
    strReportPath = fileDump.SelectedItems(1)
 

Users who are viewing this thread

Back
Top Bottom