Computing Staff
  • 2

Change All PDF Filename In Excel From Lowercase To UPPERCASE

  • 2

I want to change every PDF in a folder to uppercase, but can only use something that windows comes ready for (such as VB or Command Line/Batch files).

Share

1 Answer

  1. Here is a VBA solution, you can paste this code into any sheets or module in Excel and run the code from Sub Start.

    What this does is, ask you for the folder in which all your files are, it will them rename then all in uppsercase

    note that as you specified that you only want to rename the pdf documents, this will only rename the pdf files.

    Private Sub Start()
        Dim RootFolder
        RootFolder = BrowseForFolder
        
        Dim MyObj As Object, MySource As Object, file As Variant
        
        file = Dir(RootFolder & "")
       
        While (file <> "")
            
            If Right(file, 4) = ".pdf" Then
            
                Name RootFolder & "" & file As UCase(RootFolder & "" & file)
            End If
            
            file = Dir()
        Wend
          
    End Sub
    
    Function BrowseForFolder(Optional OpenAt As Variant) As Variant
         'Function purpose:  To Browser for a user selected folder.
         'If the "OpenAt" path is provided, open the browser at that directory
         'NOTE:  If invalid, it will open at the Desktop level
    
        Dim ShellApp As Object
    
         'Create a file browser window at the default folder
        Set ShellApp = CreateObject("Shell.Application"). _
        BrowseForFolder(0, "Please choose a folder", 0, OpenAt)
    
         'Set the folder to that selected.  (On error in case cancelled)
        On Error Resume Next
        BrowseForFolder = ShellApp.self.Path
        On Error GoTo 0
    
         'Destroy the Shell Application
        Set ShellApp = Nothing
    
         'Check for invalid or non-entries and send to the Invalid error
         'handler if found
         'Valid selections can begin L: (where L is a letter) or
         '\\ (as in \\servername\sharename.  All others are invalid
        Select Case Mid(BrowseForFolder, 2, 1)
        Case Is = ":"
            If Left(BrowseForFolder, 1) = ":" Then GoTo Invalid
        Case Is = ""
            If Not Left(BrowseForFolder, 1) = "" Then GoTo Invalid
        Case Else
            GoTo Invalid
        End Select
    
        Exit Function
    
    Invalid:
         'If it was determined that the selection was invalid, set to False
        BrowseForFolder = False
    End Function
    
    

    message edited by AlwaysWillingToLearn

    • 0