Foxtable(狐表)用户栏目专家坐堂 → 可否把一个个word文档数据汇总到表单里去呀


  共有5636人关注过本帖平板打印复制链接

主题:可否把一个个word文档数据汇总到表单里去呀

帅哥哟,离线,有人找我吗?
zhuzhi
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:一尾狐 帖子:476 积分:4039 威望:0 精华:0 注册:2011/11/2 8:55:00
  发帖心情 Post By:2022/10/13 20:46:00 [只看该作者]

老师,抱歉。我基础确实太差了,只能按照您做的代码似是而非的改一下,代码的意思也不懂。像是这个代码,我执行了,选择了我的文件,但是工号的值取不到。取出来是"—"。因为我是一段文字里的工号,不是表格。是不是要用别的办法取值啊?相片那个我是完全不懂,现在先放一放,想先学会文字内容取值,谢谢老师!
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编辑过]

 回到顶部
总数 18 1 2 下一页