I have a VBA code which opens up a dialog box in which to save my excel sheet. It is working well except one part. When the dialog box opens, it automatically opens in the folder I want to save my file in however if I click ok, it comes up with the following message:
"Path does not exist. Check the path and try again"
This error message disappears IF I select the folder again manually and then proceeds to save. I don't want to see the error message especially as the dialog box opens up to save in the correct folder in the first instance. How do i prevent having to select manually. The part of the code in which the problem lies is this:
Code
Function GetFolder(Optional sTitle As String = "Select Folder", _
Optional sInitialFilename As String)
Dim myFolder As String
With Application.FileDialog(msoFileDialogFolderPicker)
If sInitialFilename = "" Then sInitialFilename = ThisWorkbook.Path
.InitialFileName = sInitialFilename
.Title = sTitle
If .Show = -1 Then
GetFolder = .SelectedItems(1)
If Right(GetFolder, 1) <> "" Then
GetFolder = GetFolder & ""
End If
Else: GetFolder = ""
End If
End With
End Function
Display More