我试图在ms中添加每一行" *" char(代码中的$ doc2)。
$objWord = New-Object -ComObject Word.Application
$objWord.Visible = $true
$filename = 'D:\test.docx'
$objDocument = $objWord.Documents.Open($filename)
$LETable = $objDocument.Tables.Item(1)
$LETableCols = $LETable.Columns.Count
$LETableRows = $LETable.Rows.Count
$content2 = $LETable.Cell(6,2).Range.Text -replace '\r\a','' -creplace '(?m)^\s*\r?\n',''
$hl = "`n"
$content3 = $LETable.Cell(7,1).Range.Text -replace '\r\a','' -creplace '(?m)^\s*\r?\n',''
$content4 = $LETable.Cell(7,2).Range.Text -replace '\r\a','' -creplace '(?m)^\s*\r?\n',''
$doc2 = $objWord.Documents.Add()
$objWord.Selection.typetext("$content2$hl$content3$content4")
foreach ($doc2.Range().Text) | ####Something like that?