Change File Extension


Public Function GetElapsedTime(tStart, tStop) As String
Public Function ChangeFileExt(ByVal aFilename As String, ByVal NewExt As String) As Boolean
Dim p As Long
Dim bp As Long
Dim nFileName As String

On Error Resume Next
   ChangeFileExt = False
   If aFilename = "" Then Exit Function
      p = 0
      Do
        bp = p
        p = InStr(p + 1, aFilename, ".", vbBinaryCompare)
      Loop Until p = 0

      If bp > 0 Then
         nFileName = Left(aFilename, bp - 1)
      Else
         nFileName = aFilename
      End If
     nFileName = nFileName & "." & NewExt
     Err.Clear
     Name aFilename As nFileName

     If Err.Number = 0 Then ChangeFileExt = True
End Function

No comments:

Post a Comment

Post Comments


Do you have any suggestions ? Add comment. Do not spam!