excel - activeworkbook/activesheet什么时候改变?

标签 excel vba

我对 activeworkbook/activesheet 属性有一些疑问,希望得到您的帮助:

  • 在任何情况下,最多只有一个事件工作簿或没有,这适用于事件表。那正确吗?
  • 如果范围、单元格等属性在使用时不完全限定,则默认情况下它们是 activeworkbook.activesheet 的属性。那正确吗?
  • 除了激活另一个工作簿之外,事件工作簿是否会通过 vba 操作更改为另一个工作簿?
  • 当我使用 wb.ws.range(cells(x1,y1),cells(x2,y2)) 时,单元格是否暗示为 wb.ws 的单元格?还是他们需要有资格?
  • 是否可以在不激活工作簿的情况下运行存储在工作簿模块中的 vba 代码?

  • 谢谢你。

    最佳答案

    In any instances, there would be at maximum only one activeworkbook or no, and that applies to activesheet. Is that right?



    是的。 .ActiveWorkbook返回 Workbook表示事件窗口(顶部的窗口)中的工作簿的对象。

    If properties like ranges,cells,... are not fully qualified when used, they are by default meant to be that of the activeworkbook.activesheet. Is that right?



    是的
    Debug.Print rng.Parent.Name '<~~ This will give you the name
    

    Will the activeworkbook change to another workbook by vba actions other than activating the other workbook?



    对的,这是可能的。例如,如果您将事件工作簿发送到 Back如果下一个窗口在 zOrder 中,则将其最小化是一个工作簿,那么它将被激活

    When I use wb.ws.range(cells(x1,y1),cells(x2,y2)), are the cells implied to be the cells of wb.ws? Or do they need to be qualified?



    仅当 ws 处于事件状态时,否则它们将引用 Activesheet因此,完全限定您的对象总是好的
    With ws
        Set Rng = .Range(.Cells(x1, y1), .Cells(x2, y2))
    End With
    

    Is it possible to run the vba codes stored in the modules of a workbook without activating the workbook?



    是的。您可以使用 Application.Run

    关于excel - activeworkbook/activesheet什么时候改变?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44582730/

    相关文章:

    vba - 从特定工作表复制未知范围

    excel - 使用 CDate() 时,空白用户表单字段会导致不匹配错误

    python - 使用 pandas 和 openpyxl : Repaired Part:/xl/worksheets/sheet1. xml 部分时出现 Excel 错误,并出现 XML 错误。 HRESULT 0x8000ffff 第 1 行,第 0 列

    vba - 在 VBA 运行时更新图表

    c# - 有什么方法可以在 excel (vsto) 中验证单元格值

    vba - Options.DefaultHighlightColorIndex 更改后刷新内置功能区按钮并避免退出 "Text Highlight Color"

    html - VBA 选择下拉菜单网站

    excel - 自动筛选错误 : the object invoked has disconnected from its clients

    excel - 获取单元格在指定范围内的行号

    string - 如何在 MATLAB 中构造 "excel-friendly"字符串?