标题:VB从word中的字符串明明是和文件名匹配的,为何显示不匹配?
取消只看楼主
xingming022
Rank: 1
等 级:新手上路
帖 子:103
专家分:9
注 册:2015-1-26
结帖率:50%
已结贴  问题点数:20 回复次数:2 
VB从word中的字符串明明是和文件名匹配的,为何显示不匹配?
Private Sub Command6_Click()
    Dim i As Integer
    Dim j As Integer
    Dim tuhao As String
    Dim tuming As String
   
    Dim wrdapp As Object
    Dim wrddoc As Object
    Set wrdapp = CreateObject("word.application")
    Set wrddoc = wrdapp.Documents.Open(Text6.Text)


    Dim k As Integer
    Dim A As Integer
   
    Dim Myname As String
    Dim Mynamewuhouzhui As String
    Dim Mynamehouzhui As String
   
    Dim Myname2 As String
    Dim Mypath As String
    Dim Mypathname As String
    Dim Mypathname2 As String
    pltjtm.List2.Clear
   
    For k = 0 To List1.ListCount - 1
            Mypathname = List1.List(k)
            Mypath = Mid(Mypathname, 1, InStrRev(Mypathname, "\") - 1)
            Myname = Right(Mypathname, Len(Mypathname) - InStrRev(Mypathname, "\"))
            Mynamewuhouzhui = Mid(Myname, 1, InStrRev(Myname, ".") - 1)
            Mynamehouzhui = Right(Myname, Len(Myname) - InStrRev(Myname, "."))
            For i = 1 To 5
                For j = 13 To 28
                    tuhao = wrddoc.Tables(i).Cell(j, 2).Range.Text
                    tuhao = Left(tuhao, Len(tuhao) - 1)

                    A = InStr(Mynamewuhouzhui, tuhao)

                    If A > 0 Then
                        tuming = wrddoc.Tables(1).Cell(j, 3).Range.Text
                        tuming = Left(tuming, Len(tuming) - 1)
                    
                        Myname2 = Replace(Mynamewuhouzhui, Mynamewuhouzhui, Mynamewuhouzhui & " " & tuming & "." & Mynamehouzhui)
                        Name Mypath & "\" & Myname As Mypath & "\" & Myname2
                        pltjtm.List2.AddItem Mypath & "\" & Myname2
                        GoTo 11
                    End If
                Next
            Next

11:
    Next
   
    wrddoc.Close
    wrdapp.Quit

End Sub
pltjtm.rar (26.89 KB)
搜索更多相关主题的帖子: word 匹配 Dim Integer String 
2019-05-25 20:52
xingming022
Rank: 1
等 级:新手上路
帖 子:103
专家分:9
注 册:2015-1-26
得分:0 
能再问下,为何要  -2  ?您是如何发现这种解决办法的?
2019-05-26 22:20
xingming022
Rank: 1
等 级:新手上路
帖 子:103
专家分:9
注 册:2015-1-26
得分:0 
回复 5楼 风吹过b
也非常感谢您的指导,我之前有几篇帖子,您很早之前也都指点过。在这里表示下感谢。
2019-05-27 13:18



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-494942-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.252331 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved