有一个宏将表格保存为pdf格式,但它不再起作用了。这是代码:
With ActiveSheet.PageSetup
.CenterHeader = strFile2
.Orientation = xlPortrait
.PrintArea = "a1:q21"
'.PrintTitleRows = ActiveSheet.Rows(5).Address
'.Zoom = False
.FitToPagesTall = False
.FitToPagesWide = 1
End With
ws.ExportAsFixedFormat Type:=xlTypePDF, _
Filename:=strFile, _
Quality:=xlQualityStandard, _
IncludeDocProperties:=False, _
IgnorePrintAreas:=False, _
OpenAfterPublish:=False
我试过
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:=PDFFile, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=OpenPDFAfterCreating
但它给出了相同的无效过程调用或参数
问题在于我的同事宏可以工作但不能在我的电脑上工作。谢谢。
答案 0 :(得分:1)
您是否在粘贴的代码段之外声明了变量?您需要将ws声明为工作表,否则您将遇到问题:
Dim ws as Worksheet
您需要设置ws = ActiveSheet才能使用它,但我建议避免使用ActiveSheet,因为它可能导致问题。更好的是:
Set ws = Workbooks("**Name of your workbook**").Worksheets("**Name of worksheet**")
With ws.PageSetup
**code**
End With
希望有所帮助。