【VBA】查看窗口当前状态

Excle的窗口分为:最大化,最小化,一般

使用VB代码如何查看窗口的状态呢?代码如下所示:

Sub 获取窗口状态()
    Dim State As String
    State = Application.WindowState
    If State = xlMaximized Then
    MsgBox "当前窗口最大化", vbInformation
    ElseIf State = xlminized Then
    MsgBox "当前窗口最小化", vbInformation
    ElseIf State = xlNormal Then
    MsgBox "当前窗口最小化", vbInformation
    End If
End Sub

点击“运行程序”,出现如下:

image

点击下载附件

说明:

vbinformation 标识这只是一个信息提示框
原文地址:https://www.cnblogs.com/OliverQin/p/7340232.html