1
我嘗試插入一個txt文件,文件與插入對象在文檔中
$doc.selection.InlineShapes.AddOLEObject($txtFile)
但是當我運行它,我得到一個錯誤信息:
可能是什麼問題? TNX
代碼:
$Global:path = "C:\Users\user\desktop"
$txtFile = New-Item $Global:path -Name TxtFile.txt
$docx = New-Object -ComObject Word.Application
$docx.Visible = $true
$docxFileName = $docx.Documents.add()
$docx.Selection.range.InsertAfter("hello")
$docx.Selection.InlineShapes.AddOLEObject($txtFile)
$docxFileName.SaveAs([ref]$Global:path,[ref]$SaveFormat::wdFormatDocument)
$docx.Quit()
請張貼代碼 – gms0ulman
tnx。我現在提出了 – Olive