您好,欢迎来到中国最大的生活服务网站![登录][注册]
版主:Mniwtian   副版主:
点击查看所有副版主

referring to a specific

For example, in the following statement, the Font property returns a Font object contained in a Range object. Bold is a property of the Font object, not the Range object.

 

Range("A1").Font.Bold = True

 

There can be many different ways to refer to the same object.

 

Assume that you have a workbook named Sales, and it''s the only workbook open. Then assume that this workbook has one worksheet, named Summary. You can refer to the sheet in any of the following ways:

 

Workbooks("Sales.xlsx").Worksheets("Summary")

Workbooks(1).Worksheets(1)

Workbooks(1).Sheets(1)

Application.ActiveWorkbook.ActiveSheet

ActiveWorkbook.ActiveSheet

ActiveSheet

 

The method that you use is usually determined by how much you know about the workspace. For example, if more than one workbook is open, the second and third methods are not reliable. If you want to work with the active sheet (whatever it may be), any of the last three methods would work. To be absolutely sure that you''re sheet on a specific workbook, the first method is your best choice.

 

Learning more about objects and properties

If this is your first exposure to VBA, you''re probably a bit overwhelmed by objects, properties, and methods. I don''t blame you. If you try to access a property that an object doesn''t have, you get a runtime error, and your VBA code grinds to a screeching halt until you correct the problem.

用户名: 请您登录后再发帖 
标 题: 标题请勿超过30个字
内 容:
 
  请阅读我们的[服务条款]
Copyright © 2009 Yahoo.com.cn 版权所有 不得转载 | 使用须知 | 著作权声明 | 京ICP证000022号 | 国家药监局(京)-经营性-2004-0039
全球阿里巴巴 - 阿里巴巴网络:中国站 国际站 日文站 | 淘宝站 | 支付宝 | 中国雅虎 | 口碑网 | 阿里软件 | 阿里妈妈