Dim app As New MSWord.Application
Try
Dim doc = app.Documents.Open("D:\问题\试验.doc")
Dim r As Row = Tables("表A").AddNew
Dim n12 As Boolean
For Each k As Object In doc.Paragraphs
Dim s As String = k.Range.text.tostring
If s.Contains("工号:") Then
Dim idx As Integer = s.IndexOf("工号:")
MsgBox(s.Substring(idx))
r("工号") = s.Substring(idx)
ElseIf s.Contains("1.预计12月所在地") Then
n12 = True
ElseIf s.Contains("第一空:") Then
If n12 = True Then
Dim idx As Integer = s.IndexOf("第一空:")
MsgBox(s.Substring(idx))
r("预计12月所在地") = s.Substring(idx)
n12 = False
End If
End If
'output.show(k.Range.text.tostring)
Next
app.ActiveWindow.Selection.WholeStory
For Each shape As Object In app.ActiveWindow.Selection.InlineShapes
Try
Output.Show(shape.name)
Catch ex2 As exception
msgbox(ex2.message)
End Try
If shape.Type = MSWord.WdInlineShapeType.wdInlineShapePicture Then
Dim img As Byte() = shape.Range.EnhMetaFileBits
Dim bmp As New Bitmap(New IO.MemoryStream(img))
'bmp.Save(ProjectPath & "Attachments/00011.jpg")
bmp.Save(ProjectPath & "Attachments/" & r("工号") & ".jpg")
r("第四列") = r("工号") & ".jpg"
End If
Next
app.quit
Catch ex As exception
msgbox(ex.message)
app.quit
End Try