Originally Posted by
xld
Try this
With Application.FileDialog(msoFileDialogOpen)
.AllowMultiSelect = False
If .Show = -1 Then
OldFilename = .SelectedItems(1)
Name OldFilename As NewFilename
End If
End With
Dear xld,
Thank you for the answer. I just managed to get it with another code.
Sub MoveFile() Dim NewPath As String, NewFilename As String, SelectedFile As String
NewPath = "D:\temp\" 'Note the trailing backslash
NewFilename = "NewName2"
SelectedFile = Application.GetOpenFilename
If SelectedFile <> "False" Then
NewFilename = NewPath & NewFilename & Mid(SelectedFile, InStrRev(SelectedFile, "."))
Name SelectedFile As NewFilename
End If
End Sub
For the people that are interested. I only have one guestion remaining.
How can i get the file extension? i want the extension being put in an textbox with the name "textbox2".
and by the extension i mean, .PDF or .XLS and so on.
Thank you