我注意到我有时会收到错误:
在Excel VBA中运行时错误'''
:对象不支持此属性或方法
但是如果我先在对象上调用.select
,那么此错误就会消失。
例如,我最近想要更改工作表上某些链接图像的大小,并使用宏录制器录制了以下内容:
ActiveSheet.Shapes.Range(Array("Picture 3")).Select
Selection.ShapeRange.Height = 303.12
这段代码显然工作正常。然后我按如下方式更改了代码:
Dim sheetReport as Worksheet
Set sheetReport = Worksheets("Report")
With sheetReport
Dim pictureNumber As Long
For pictureNumber 1 to 3
.Shapes.Range("Picture " & pictureNumber).ShapeRange.Height = 303.12
Next pictureNumber
End With
现在我收到上面提到的错误但如果我然后将此代码更改为
Dim sheetReport as Worksheet
Set sheetReport = Worksheets("Report")
With sheetReport
Dim pictureNumber As Long
For pictureNumber 1 to 3
.Shapes.Range("Picture " & pictureNumber).Select
Selection.ShapeRange.Height = 303.12
Next pictureNumber
End With
再次有效。但我当然不应该只选择每张图片以改变其Height
属性吗?
答案 0 :(得分:4)
这在我的测试运行中运行良好。
SELECT MAX(sum_total_pay)
FROM
(
SELECT SUM(ALLOCATION.HourlyRate * ACTION.HrsWorked) AS sum_total_pay
FROM ALLOCATION
INNER JOIN ACTION
ON ((ACTION.ActId = ALLOCATION.ActId) AND (ACTION.EmpId = ALLOCATION.EmpId))
GROUP BY (ALLOCATION.ActId)
);