I think you want to get the file selection before DoCmd.TransferSpreadsheet
, because the file selection is the transfer target.
I'm not sure exactly what you want, but I think this should be a step closer ...
Private Sub CommandBtn_Click()
Dim fileSelection As Object
Dim strPath As String
Set fileSelection = Application.FileDialog(2)
With fileSelection
.AllowMultiSelect = False
If .Show = True Then
strPath = .SelectedItems(1)
' use strPath with TransferSpreadsheet ...
'DoCmd.TransferSpreadsheet
Else
MsgBox "no file selected"
End If
End With
End Sub