我写法上是不是有什么不对,提示出错Dim fl As String = ProjectPath & "test.docx"
Dim fl1 As String = ProjectPath & "test1.docx"
FileSys.CopyFile(fl,fl1,True)
Dim img As String = ProjectPath & "印章.png"
Dim app As New MSWord.Application
try
Dim doc = app.Documents.Open(fl1)
app.Selection.Find.Text = "盖章"
app.Selection.Find.Execute
Dim pic = app.Selection.InlineShapes.AddPicture(img, False, True)
With pic
.WrapFormat.Type = wdWrapFront
.LockAspectRatio = msoCTrue '锁定纵横比
.Height = CentimetersToPoints(2) '缩小为原来的20%
.RelativeHorizontalPosition = wdRelativeHorizontalPositionRightMarginArea '相对于右边距
.Left = -.Width '取图片宽度的负数
.RelativeVerticalPosition = wdRelativeVerticalPositionBottomMarginArea '相对于下边距
.Top = -.Height '取图片高度的负数
.LockAspectRatio = True
.Height = 100
End With
Doc.SaveAs(Filename:= fl1)
catch ex As exception
msgbox(ex.message)
app.Quit
finally
End try
Dim Proc As New Process
Proc.File = fl1
Proc.Start()