View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.programming
Rob Rob is offline
external usenet poster
 
Posts: 234
Default Find file and remove .csv extension

Hi,

I'm tring to open a window, select a file with CSV extension, the file is
coded to SelectedFile and then remove I want to remove the .CSV before
renaming the file with the same name albeit with a .TXT extension.

I've tried the code below for the inital test but it fails on the
WorksheetFunction code.

Am I on the right track?

Thanks, Rob
Sub macro1()

Dim Filter, Caption, SelectedFile, DestinationFile As String

Filter = "Text files (*.csv),*.csv"
Caption = "Please Select a File " & TheUser
SelectedFile = Application.GetOpenFilename(Filter, , Caption)

SelectedFile = Application.WorksheetFunction _
.Left(SelectedFile, Find(".CSV", (.Upper(SelectedFile)), 1) - 1)

Debug.Print SelectedFile

End Sub