Hello,

I am trying to build a macro that prompts a user to select a folder and then creates a workbook and saves it in that folder. The problem I am having is that this new workbook is always saved at My Documents instead of the selected folder. I have a function (copied it from the web) that from what I understand creates a daialog box to select the folder, and then a sub which stores that folder into a variable. Then yet, a third sub that runs the first sub and then copies some cells to the new workbook.

here is the code:

Function
Public Function SelectFolder(Optional title As String, Optional top_folder As String) As String
    Dim objShell As New Shell32.Shell, _
        objFolder As Shell32.folder
    
    Set objetFolder = objShell.BrowseForFolder(0, title, 1, TopFolder)
    If Not objFolder Is Nothing Then
        SelectFolder = objFolder.Items.Item.Path
    End If
End Function
Macro 1
Public Sub FolderSelection()
    Dim MyPath As String
    
    MyPath = SelectFolder("Selecciona una carpeta en donde guardar el reporte.", "")

End Sub
Macro 2
Sub Generar()
'
'   Guarda reporte en archivo nuevo

    Dim new_report As Workbook
    Dim user As String
    Dim report_key As String
    Dim file_path As String
    
    user = Sheets("TABLES").Range("P3").Value
    report_key = Sheets("TABLES").Range("Q3").Value
    
    FolderSelection
    file_path = MyPath & user & report_key
    
    Set new_report = Workbooks.Add()
    new_report.SaveAs Filename:=file_path & ".xls"
    
    Windows("Formas.xls").Activate
    Sheets("TABLES").Activate
    Range("A7:J7").Select
    Range(Selection, Selection.End(xlDown)).Select
    
    Selection.Copy
    Windows(2).Activate
    Range("A1").Select
        Selection.PasteSpecial Paste:=xlPasteValues, Operation:=xlNone, SkipBlanks _
        :=False, Transpose:=False
    Application.CutCopyMode = False
    Range("A1").Select
    
    ActiveWorkbook.Save
    ActiveWorkbook.Close
    
    Windows("Formas.xls").Activate
    Range("A1").Select
End Sub
Thanks so much