0
0

Test

Posted at
Sub AdjustRowHeightInAllExcelFiles()
    Dim folderPath As String
    folderPath = "C:\Your\Folder\Path" ' フォルダパスを指定してください
    
    ProcessFolder folderPath
End Sub

Sub ProcessFolder(ByVal folderPath As String)
    Dim fileSystem As Object
    Dim folder As Object
    Dim file As Object
    Dim subfolder As Object
    
    Set fileSystem = CreateObject("Scripting.FileSystemObject")
    Set folder = fileSystem.GetFolder(folderPath)
    
    For Each file In folder.Files
        If LCase(Right(file.Name, 5)) = ".xlsx" Or LCase(Right(file.Name, 4)) = ".xls" Then
            AdjustRowHeight file.Path
        End If
    Next file
    
    For Each subfolder In folder.Subfolders
        ProcessFolder subfolder.Path
    Next subfolder
End Sub

Sub AdjustRowHeight(ByVal filePath As String)
    Dim wb As Workbook
    Dim ws As Worksheet
    Dim rowHeight As Double
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    
    Set wb = Workbooks.Open(filePath)
    
    For Each ws In wb.Worksheets
        With ws.Rows(2)
            .AutoFit
            rowHeight = .RowHeight
            .RowHeight = rowHeight + 10
        End With
        ws.Range("A1").Select
    Next ws
    
    wb.Save
    wb.Close
    
    Application.DisplayAlerts = True
    Application.ScreenUpdating = True
End Sub
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0