我正在尝试编写一个宏来批量处理一堆Word文档。我需要将页面大小设置为“Legal”,超过200个文件。我编写的代码非常简单,看起来应该可以工作,但是我无法获得Documents.Open命令来成功执行。每次我得到这个结果:
运行时错误'5174':找不到此文件。
(等等) - 即使我对文件名进行硬编码。该文件确实存在。这是我到目前为止所得到的:
Public Sub MassFormatLegal()
Dim vDirPath As String
Dim vFile As String
Dim vFileName As String
Dim oDoc As Document
vDirPath = "MacMiniHD:Users:atc:Documents:TEST:"
vFile = Dir(vDirPath)
Do While vFile <> ""
vFileName = vDirPath & vFile
'* display the filename to verify that it's correct
MsgBox "vFileName: " + vFileName
'* open file
Set oDoc = Documents.Open("MacMiniHD:Users:atc:Documents:TEST:AAFILE.doc")
'* I also tried the following, all resulting in the same error
'*Set oDoc = Documents.Open(vFileName)
'*Set oDoc = Documents.Open(fileName:=vFileName)
'*Set oDoc = Application.Documents.Open(fileName:=vDirPath & vFile)
'* change paper size
oDoc.PageSetup.PaperSize = wdPaperLegal
'* save and close the document
oDoc.Close wdSaveChanges
'* get next file
vFile = Dir
Loop
MsgBox "Finished"
End Sub
有什么建议吗?我尝试了很多不同的方法,并且意识到VBScript for Mac存在严重的局限性,但是这种基本的文件处理肯定可以吗?!