宏判断是否为Excel打开,若不是则关闭表格

宏代码:

Public Function is_wp()
    Debug.Print "Application.Build:" & vbCrLf & Application.Build
    Debug.Print "Application.Caption:" & vbCrLf & Application.Caption
    Debug.Print "Application.ActiveWorkbook.Name:" & vbCrLf & Application.ActiveWorkbook.Name
    
    is_wp = InStr(Replace(UCase(Application.Caption), UCase(Application.ActiveWorkbook.Name), ""), "WPS") > 0
    If Application.Caption <> "工作人员通讯录.xlsm - Excel" Then
        ActiveWorkbook.Close Savechanges:=False
    End If

  

Private Sub Workbook_Open()
Call Sheet1.is_wp
Call Sheet1.main
End Sub

 

posted @ 2021-08-06 18:15  xiaoxiaosen  阅读(155)  评论(0编辑  收藏  举报