Excel VBA上的错误“400” - PDF打印

时间:2017-09-20 05:47:14

标签: excel vba excel-vba pdf

我收到错误'400'消息框 - (没有其他信息/文本显示),同时尝试按以下方式运行以下代码。我在VBA中没有过多的经验,并且从其他工作簿中复制了此代码并进行了相应的调整。简而言之,代码会查看下拉列表/数据透视表过滤器,并在指定的文件夹位置创建,命名和保存PDF。任何帮助,将不胜感激! &安培;先感谢您! :)下面是我正在使用的以下代码:

Sub PDFReports()

Dim Dropdown1 As String
Dim Range1 As Range
Dim option1 As Range
Dim counter As Long
Dim cellcontents As String
Dim SaveAsStr As String

counter = 1
Dropdown1 = "j3"

Set Range1 = Evaluate(Range(Dropdown1).Validation.Formula1)

For Each option1 In Range1
ActiveSheet.Range("j3").Select
  ActiveCell.Value = option1.Value 'change dropdown value
   SaveAsStr = "Y:\002 Data Program Documents\001 Practice Data Reports" & _
   ActiveSheet.Range("J3").Value 'save pdf with value in dropdown in filename
   ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
       SaveAsStr & " Data Report " & Format(Now, "dd-mm-yy") & ".pdf"
    counter = counter + 1
Next option1

    MsgBox "Reports complete"

End Sub

0 个答案:

没有答案