Using msoFileDialogFolderPicker to select a folder

Anonymous
2014-09-18T12:08:33+00:00

Hello

The following code is written to allow the user to select the folder where they wish to save a PDF of the worksheet and the file name will consist of data located in cells D4 and D5.  It also checks to confirm that the data in cell D5 contains 3 characters.  The code works fine but with one issue.  If the user drills down say 4 levels of subfolders the file does not save in the folder, it saves in the folder one level up. 

I can't figure out why the file is not saved it the folder selected.

Can someone indicate what I am missing?

Thank you

Microsoft 365 and Office | Excel | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
{count} votes
Answer accepted by question author
  1. Anonymous
    2014-09-18T13:00:19+00:00

    Hi

    Have a try with this

    Dim strCurrDir As String

    Dim fldpath As String

    Debug.Print CurDir

    strCurrDir = CurDir 'keep track of current directory

    Application.FileDialog(msoFileDialogFolderPicker).Show

    Debug.Print CurDir

    fldpath = Application.FileDialog(msoFileDialogFolderPicker).SelectedItems(1)

    ChDir fldpath 'chang to the new directory

    Debug.Print CurDir

    'Do your stuff

    ChDir strCurrDir 'reset to previous current directory

    End Sub

    HTH

    Regards

    JY

    2 people found this answer helpful.
    0 comments No comments

9 additional answers

Sort by: Most helpful
  1. Anonymous
    2014-09-18T13:02:37+00:00

    Try fully specifying the path on the export:

    Filename:=FldPath & "\ENG-" etc....

    0 comments No comments
  2. Deleted

    This answer has been deleted due to a violation of our Code of Conduct. The answer was manually reported or identified through automated detection before action was taken. Please refer to our Code of Conduct for more information.


    Comments have been turned off. Learn more

  3. Anonymous
    2014-09-18T13:12:08+00:00

    Try fully specifying the path on the export:

    Filename:=FldPath & "\ENG-" etc....

    I have tryed this but all I get is the file still in the wrong folder except the file name begins with the folder name I had selected for it to save in.

    0 comments No comments
  4. Anonymous
    2014-09-18T13:19:18+00:00

    Post your actual code, not just a picture of it....

    0 comments No comments