Please read this post carefully. To have a user file
folder selection passed to code (or a macro I suppose) you'd call a custom function in the macro or code and it would return the choice. You'd then use that choice in place of the path that you would otherwise have to "hard code" in your macro/code. You can use this in conjunction with whatever you've already got, but allow the user to specify a place to keep whatever it is you are trying to store. The code for or choosing a
file from a folder location is similar, but not exactly the same as what I posted below, which you can modify to suit. Calling the function is like this: if in code you are now saying 'path = "C:\blah\blah", you now say path=getFilePath (no quotes). Note that I am adding a "\" at the end of the path string. If you need to go a level further and pass the complete path - including the file name - you need to use the
file dialog unless you append the file name to the value of vrtSelectedItem (see code). You will need to modify some of the settings such as ButtonName.
Code:
Function getFilePath() as String
Dim fd As FileDialog
Dim vrtSelectedItem As Variant
Set fd = Application.FileDialog(msoFileDialogFolderPicker)
With fd
'.AllowMultiSelect = False
.ButtonName = "Choose Folder"
.Title = "Choose Scope Text Folder"
.Filters.Clear
'.Filters.Add "Text Files", "*.txt", 1
'.InitialFileName =
'.InitialView = msoFileDialogViewList
If .Show = -1 Then
vrtSelectedItem = .SelectedItems.Item(1) & "\" 'multi-select not allowed, so we can specify the item by index
'The user pressed Cancel.
Else
Exit Function
End If
End With
getFilePath = vrtSelectedItem
End Function
Your issues are not clear to me. If you are having a problem with user permissions on the place the user is trying to save, or they cannot modify database tables due to permissions, this will not help.
One other comment at this point: You indicated in your pm that employee records are first being deleted, then re-built in this process. I wonder about that because it would generally be considered bad practice. If the rebuild process fails, then you have no records? There is a protection for this, but the first choice would be to not design so that this is a regular occurrence. Since you seem to be sharing compartmentalized data over a distance, perhaps you should read up on 'database replication'.