我在Excel VBA中创建了一个程序,该程序从Word文档内容复制并将其粘贴到邮件正文中。但我尝试更改文档中一段文本的方向并使用
.ParagraphFormat.Alignment
但没有成功。
我试过这个代码
Sub sendMail()
Dim ol As Outlook.Application
Dim olm As Outlook.MailItem
Dim wd As Word.Application
Dim doc As Word.Document
Dim Cell As Range
For r = 23 To Sheet1.Cells(Rows.Count, 21).End(xlUp).Row
With wd.Selection.Find
.Text = "<<Duration>>"
.Replacement.Text = Sheet1.Cells(r, 32).Value
.Execute Replace:=wdReplaceAll
End With
With wd.Selection.Find
.Text = "<<objectivs>>"
.ParagraphFormat.Alignment = wdAlignParagraphLeft 'this code suppose to change the direction but it didn't work
.Replacement.Text = Sheet1.Cells(r, 33).Value
.Execute Replace:=wdReplaceAll
End With
Next
End Sub
尝试
.Replacement.ParagraphFormat.Alignment = wdAlignParagraphLeft