Help!
Users run a small macro that requires they specifiy some data to look for in a remote file. The program will give them the File | Open dialog, they choose a file from the list and then several forms ask for the type of data they need to filter for in the original file.
This filtered data is copied and placed into a template-generated workbook where they can further filter if they need to. They then can save the new file in a desired location. Because of the file’s content, the file will normally be saved into a location that is different to their individual default file locations.
I have declared a global string variable for ‘DefFileLoc’ and used the following to determine their default location (as per the Tools | Options | General | Default file location: command)
Global DefFileLoc As String ‘ in Declarations section
DefFileLoc = Application.DefaultFilePath ‘ to get the current default file location
This is OK when I have stepped through the code and noted that the path is indeed e.g ‘C:My Documents’
I did write the following code to change the default back, but it has no effect as it only remembers the last location the user used.
‘ Change back to the users original DefaultFilePath
With Application
.DefaultFilePath = DefFileLoc
End With
When the user elects to put their files away in ‘H:Quality Data’ for example, the default file location is changed to the new location.
I am sure that it can be done. but I seem to have not found the answer. Any suggestions on how I should be using the object variable to remember the default file location so that it can be re-used when the user has closed the files that go to the alternate location and return the default file location back to how it was when the user started MS Excel would be appreciated.
Leigh