我的问题是关于在此转换脚本中保存文件的错误:
https://github.com/idf/batch_dump/blob/master/office_convert.ps1
#Error
Exception when calling "InvokeMember" with "6" argument (s): "Object does not match destination type."
In the line: 28 character: 1
+ $workbook = $objExcel.Workbooks.PSBase.GetType().InvokeMember('Open', ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : TargetException
saving C:\Test\CD_FEV_1.pdf
You can not call a method on a null value expression.
In the line: 30 character: 1
+ $workbook.ExportAsFixedFormat($xlTypePDF, $filepath, $xlQualityStanda ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
You can not call a method on a null value expression.
In the line: 31 character: 1
+ [void]$workbook.PSBase.GetType().InvokeMember('Close', [Reflection.Bi ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
由于我没有体验过PowerShell,我不会理解他们用脚本调用的方法。
答案 0 :(得分:0)
我自己仍然是PowerShell的新手,因此无法具体回答导致错误的原因,但我认为我找到了解决方案。它似乎只有Excel转换。 Word和PPT转换完美无瑕。我已经更改了该部分的代码,现在似乎正在运行:
def printWord(begin, mid, end, r):
print(begin, end="")
for i in range(r+1):
print(mid, end="")
print(end)
begin = input("Enter your beginning.\t")
mid =input("Enter your middle.\t")
end = input("Enter your ending.\t")
r = int(input("How many times?\t"))
printWord(begin, mid, end, r)