本示例使用 With 语句对某单一对象执行一系列的语句。MyObject 对象及其属性均为示范目的而采用了通用名称。

With MyObject
   .Height = 100      ' 和 MyObject.Height 一样等于 100 。
   .Caption = "Hello World"   ' 和 MyObject.Caption 一样等于 "Hello World" 。
   With .Font
      .Color = Red      ' 和 MyObject.Font.Color 一样等于 Red。
      .Bold = True      ' 和 MyObject.Font.Bold 一样等于 True 。
   End With
End With

with sheet1
.range("a1")=...
.name=...
end with