老师,抱歉。我基础确实太差了,只能按照您做的代码似是而非的改一下,代码的意思也不懂。像是这个代码,我执行了,选择了我的文件,但是工号的值取不到。取出来是"—"。因为我是一段文字里的工号,不是表格。是不是要用别的办法取值啊?相片那个我是完全不懂,现在先放一放,想先学会文字内容取值,谢谢老师!Dim dlg As new OpenFileDialog
dlg.MultiSelect = True
If dlg.ShowDialog = DialogResult.OK Then
Dim app As New MSWord.Application
try
If FileSys.DirectoryExists(ProjectPath & "Attachments") = False Then
FileSys.CreateDirectory(ProjectPath & "Attachments/")
End If
For Each filename As String In dlg.FileNames
Dim doc = app.Documents.Open(fileName)
Dim nr As Row = Tables("表A").AddNew
Dim t = doc.Tables(1)
Dim text = t.Cell(1, 2).Range.Text.ToString()
text = text.Substring(0, text.Length - 2)
nr("工号") = text
'-------------
app.ActiveWindow.Selection.WholeStory
For Each shape As object In app.ActiveWindow.Selection.InlineShapes
If shape.Type = MSWord.WdInlineShapeType.wdInlineShapePicture
Dim img As Byte() = shape.Range.EnhMetaFileBits
Dim bmp As new Bitmap(new IO.MemoryStream(img))
bmp.Save(ProjectPath & "Attachments/" & nr("工号") & ".jpg")
End If
Next
nr("第四列") = nr("工号") & ".jpg"
Doc.Close
Next
catch ex As exception
msgbox(ex.message)
finally
app.Quit
End try
End If
[此贴子已经被作者于2022/10/13 20:48:23编辑过]