在Excel VBA中设置活动工作簿的值 [英] Setting value of active workbook in Excel VBA
问题描述
这是否有意义?
以下是我现在正在使用的,我想要做的是针对 ActiveWorkbook
或可以使用一些类似的东西。因为这将被设置在代码的开头,而不是中间。
设置wbOOR = Application.Workbooks(打开订单Report.xlsm )
你可能在之后设置wbOOR = ThisWorkbook
只是为了澄清
ThisWorkbook
将始终引用代码所在的工作簿
ActiveWorkbook
将引用活动的工作簿
在处理多个工作簿时,请注意如何使用它。这真的取决于你想要实现哪一个是最好的选择。
I for now have my workbook set up this way, in where the workbook is hard coded into the Set command, I am wondering if there is a way of doing this so I can have it where it is fluid? So no matter where this code is place (in another workbook) the code will adapt to it's new surroundings.
Does this make sense?
Below is what I am using now, what I'd like to have it do is for the ActiveWorkbook
or something of the sort be used instead. Since this will be set at the beginning of the code and not the middle.
Set wbOOR = Application.Workbooks("Open Order Report.xlsm")
You're probably after Set wbOOR = ThisWorkbook
Just to clarify
ThisWorkbook
will always refer to the workbook the code resides in
ActiveWorkbook
will refer to the workbook that is active
Be careful how you use this when dealing with multiple workbooks. It really depends on what you want to achieve as to which is the best option.
这篇关于在Excel VBA中设置活动工作簿的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!