ドロップダウンリストのフォントサイズを大きくする方法が見つからなかったため、回避策を見つける必要がありました。1つのオプションはズームインすることです。したがって、私はこのコードを持っています-これは完全に機能します。しかし、ファイルを閉じて再度開こうとすると、「オブジェクト変数またはブロック変数が設定されていません」というエラーメッセージが表示されます。
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo errorHandler
Dim xZoom As Long
xZoom = 60
If Target.Validation.Type = xlValidateList Then xZoom = 125
errorHandler:
ActiveWindow.Zoom = xZoom 'Debug highlights this row
End Sub
私はイベントを試しました:
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo errorHandler
Dim wb as Workbook
Dim xZoom As Long
xZoom = 60
Set wb = ThisWorkbook
wb.Activate
If Target.Validation.Type = xlValidateList Then xZoom = 125
errorHandler:
ActiveWindow.Zoom = xZoom 'Debug highlights this row
End Sub
しかし、何も機能していないようです...原因が何であるかわかりません...誰か助けてくれませんか?
ズームを行う前に、windows.count> 0であることを確認してください。
If Application.Windows.Count > 0 Then
ActiveWindow.Zoom = xZoom
End If
Private Sub Worksheet_SelectionChange(ByVal Target As Range)
On Error GoTo errorHandler
Dim xZoom As Long
xZoom = 60
If Target.Validation.Type = xlValidateList Then
xZoom = 125
If Application.Windows.Count > 0 Then
ActiveWindow.Zoom = xZoom 'Debug highlights this row
End If
End If
Exit Sub 'must exit before the error handler
errorHandler:
Msgbox(Err.Description)
End Sub
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加