Excel VBA-Sheets.Printout我不知道为什么会这样,但是仍然会抛出错误?

时间:2020-08-19 18:59:29

标签: excel vba

我有以下有效的代码,但抛出了

"Run-time '1004' Unable to set the Printout property of the worksheet class"

这是代码:

Sub PrintOutv1()

'PrintOutv1 Macro
Dim Val As Double
Val = ActiveWorkbook.Sheets("WU").Range("E1").Value
ActiveWorkbook.Sheets("WU").PrintOut(1, Val, 1, True) = True

1 个答案:

答案 0 :(得分:0)

肢体再次叮咬!在参数周围加上括号,不要尝试赋值:

Dim myVal As Double '<~ avoid confusion with the Val function
myVal = ActiveWorkbook.Sheets("WU").Range("E1").Value

ActiveWorkbook.Sheets("WU").PrintOut 1, myVal, 1, True