Greetings knowledgeable sages,
I would like to create additional Excel workbooks in a folder/directory where a master workbook is located (or potentially one level up in the directory hierarchy). I have various template files, so want the user be able to select the specific file to spawn from, but do not want the user to have to navigate through the entire path. (Or another way to do this would just be to have all the templates in a set directory, and have the user pick which one to use, ideally from an Open File dialog...)
It does not seem like there is an option in Application.GetOpenFilename to use the path. So is there another function that would open a dialog in the proper directory for the user to select the file from which to open a new file?
I would like to create additional Excel workbooks in a folder/directory where a master workbook is located (or potentially one level up in the directory hierarchy). I have various template files, so want the user be able to select the specific file to spawn from, but do not want the user to have to navigate through the entire path. (Or another way to do this would just be to have all the templates in a set directory, and have the user pick which one to use, ideally from an Open File dialog...)
It does not seem like there is an option in Application.GetOpenFilename to use the path. So is there another function that would open a dialog in the proper directory for the user to select the file from which to open a new file?
Code:
Dim FolderPathName As String ' the path for the current Master Data Sheet
Dim TemplateToUse As Variant ' the file that the user selects
Dim nwb As Workbook ' new Workbook to modify, from the selected Template
' find the latest Prototype to use
FolderPathName = ActiveWorkbook.Path
TemplateToUse = Application.GetOpenFilename() ' any way to get this to go to the FolderPathName?
If TemplateToUse = False Then Exit Sub
Set nwb = Workbooks.Open(TemplateToUse)
' do stuff to modify nwb and save off as a new file name in the same path as the master workbook
TemplateToUse.Close savechanges:=False
End Sub