当 TypeTexting 到 word 文档时内容被截断
Content getting truncated when TypeTexting to word document
当我尝试将一个长文本文件键入文本到 word 文档时,内容被截断了 3200 个字符,总共 27 页,即使我粘贴时完整内容大约有 6000 个字符和 60 页长手动。这是我的代码:
$Source1 = Get-Content -Path FileSystem::C:\Users\My_user\Desktop\file.txt -Raw;
$Word = New-Object -ComObject Word.Application;
$Word.Visible = $True;
$Document = $Word.Documents.Add();
$Selection = $Word.Selection;
$Selection.TypeText($source1);
official documentation doesn't mention a length limit, although this forum post提示是64KB。
虽然这并不能解释您仅使用 6,000
个字符的问题,但请考虑改用 .InsertFile
method(未经测试):
$Selection.InsertFile('C:\Users\My_user\Desktop\file.txt')
当我尝试将一个长文本文件键入文本到 word 文档时,内容被截断了 3200 个字符,总共 27 页,即使我粘贴时完整内容大约有 6000 个字符和 60 页长手动。这是我的代码:
$Source1 = Get-Content -Path FileSystem::C:\Users\My_user\Desktop\file.txt -Raw;
$Word = New-Object -ComObject Word.Application;
$Word.Visible = $True;
$Document = $Word.Documents.Add();
$Selection = $Word.Selection;
$Selection.TypeText($source1);
official documentation doesn't mention a length limit, although this forum post提示是64KB。
虽然这并不能解释您仅使用 6,000
个字符的问题,但请考虑改用 .InsertFile
method(未经测试):
$Selection.InsertFile('C:\Users\My_user\Desktop\file.txt')