简体   繁体   English

Excel VBA 选择要打印的单元格 - 设置打印区域

[英]Excel VBA choose cells to print - Set Print Area

I want to choose the print area using VBA and print them out.我想使用 VBA 选择打印区域并将它们打印出来。

I have tried this method, but it gives me an error我试过这个方法,但它给了我一个错误

This formula is missing a range reference or a defined name此公式缺少范围引用或定义的名称

Worksheets("Printable Version").Activate
With Sheets("Printable Version")
    ActiveSheet.PageSetup.PrintArea = .Range("A1").Value & ":" & .Range("G55").Value
End With
With Sheets("Printable Version")
    .PageSetup.PrintArea = .Range("A1:G55").Address
    '''Or
    .PageSetup.PrintArea = "A1:G55"
    .PrintOut
End With

我用这段代码弄清楚了:

WorkSheet("sheetname").range("A1:G55").printout

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM