if Excel Workbook is open then… VBA

后端 未结 3 1853
忘了有多久
忘了有多久 2021-01-19 03:45

How could I write code to say.

    Dim xlApp As Excel.Application
    Dim xlWorkbook As Excel.Workbook
    Dim xlWorksheet As Excel.Worksheet
3条回答
  •  隐瞒了意图╮
    2021-01-19 04:25

    This might be going in the wrong direction but here's something I've used in the past..

        If Workbooks.Count > 1 Then 'Or in your case = 0
           'Do Something Here'
        Else
           'Do Something Else'
        End If
    

    That way it will tell you if you have more than one workbook open. Otherwise it sounds like you ARE looking to see if something specific is open.

    Hope that helps.

提交回复
热议问题