请不要标记重复项,因为我已经正确地检查了特定于错误91的其他相关解决方案,但没有一个人似乎为我解决我遇到的问题提供了解决方案。VBA错误91-对象或块变量未设置
我试图使用以下VBA代码将嵌套在各种文件夹(大约500个文件)中的我的coreldraw文件转换为其应用程序,或者显示错误91'对象或未设置块变量'。与我创建的其他演示文件集一起使用时,相同的代码绝对可以正常工作。
我可以推测的一种情况是在处理脚本时显示一些对话框的文件。如果是,我应该如何阻止这些对话框。 Application.DisplayAlerts = False在coreldraw中不起作用。
但是,这种情况只是一个假设。有人能帮我找到问题吗?继承人的代码
Sub NewFolder()
Dim FileSystem As Object
Dim HostFolder As String
HostFolder = "My folder Path"
Set FileSystem = CreateObject("Scripting.FileSystemObject")
DoFolder FileSystem.GetFolder(HostFolder)
End Sub
Sub DoFolder(folder)
Dim SubFolder
For Each SubFolder In folder.SubFolders
DoFolder SubFolder
Next
Dim File
For Each File In folder.Files
If InStr(File.Name, ".cdr") Then
Application.OpenDocument (File)
End If
Dim filepath As String
filepath = ActiveDocument.FullFileName
Dim doc1 As Document
Dim SaveOptions As StructSaveAsOptions
Set SaveOptions = CreateStructSaveAsOptions
Set doc1 = ActiveDocument
With SaveOptions
.EmbedVBAProject = True
.Filter = cdrCDR
.IncludeCMXData = False
.Range = cdrAllPages
.EmbedICCProfile = True
.Version = cdrVersion17
End With
doc1.SaveAs filepath, SaveOptions
doc1.Close
' Operate on each file
Next
End Sub
调试错误消息,当知道世界卫生大会通常帮助t行正在抛出错误。 – Jeeped