0
我正在嘗試創建一個VBA腳本,用於更改保存在一個文件夾中的多個工作簿中的字體。但是,它不起作用。請看看代碼Excel 2010:幫助更改多個工作簿中的字體
Sub changefont()
Dim wb As Workbook, sh As Worksheet, fpath As String, fname As String
fpath = "D:\reports"
If Right(fpath, 1) <> "\" Then fpath = fpath & "\"
fname = Dir(fpath & ".xls")
Do
On Error Resume Next
Set wb = Workbooks.Open(fname)
Set sh = wb.Sheets("REPORT")
On Error GoTo 0
If Not sh Is Nothing Then
With sh.Range(Cells(10, 1), Cells(90, 11))
.Font.Size = "18"
.Font = "Arial"
End With
End If
wb.Close True
fname = Dir
Loop While fname <> ""
End Sub
注:我的工作表Sheet1被命名爲報告中的所有工作簿
請修復縮進。 –