excel - 为什么我的 ExportAsFixedFormat 不起作用?
问题描述
几天前,此宏成功保护了所有工作表,并将工作簿的 PDF 副本保存在放置 excel 文件的同一文件夹地址中。
今天我尝试运行宏,当涉及到 PDF 步骤时,它会显示消息
运行时错误 5:无效的过程调用或参数
我该如何解决?
谢谢你们
Sub pdf()
'
' pdf Macro
'
'
Dim pwd1 As String, pwd2 As String
pwd1 = InputBox("Please Enter the password")
If pwd1 = "" Then Exit Sub
pwd2 = InputBox("Please re-enter the password")
If pwd2 = "" Then Exit Sub
'Check if both the passwords are identical
If InStr(1, pwd2, pwd1, 0) = 0 Or _
InStr(1, pwd1, pwd2, 0) = 0 Then
MsgBox "You entered different passwords. No action taken"
Exit Sub
End If
For Each ws In Worksheets
ws.Protect Password:=pwd1
Next
MsgBox "All sheets Protected."
ActiveWorkbook.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & ActiveWorkbook.Name _
, Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas _
:=False, OpenAfterPublish:=True
End Sub
解决方案
推荐阅读
- vue.js - 如何使用 Vue 组件 $set 在单个文件组件中设置对象
- c++ - 在 C++17 中表达 std::byte 文字的正确方法是什么?
- configuration - xmr-stak 开采门罗币的最佳配置是什么?
- javascript - 在使用鼠标滚轮而不是 3 行滚动时,使滚动条逐行跳转
- python - Python 构建复杂的 mypy 类型
- flutter - 颤振将日期字符串转换为int
- azure - azure devops 中的 Azure 资源组部署失败并出现错误 ["Message": "Deployment with id '#######' exists"]
- list - 如何为不和谐机器人创建一个特定的命令来存储一些输入信息?
- actionscript-3 - “is MovieClip”是真的,但编译器坚持它不是并抛出错误 #1034: Type Coercion failed? (AS3)
- android - 在 android 9.0 中打开时对话框闪烁和故障