VBA检测文本颜色IBM PCOMM

时间:2017-08-11 18:58:45

标签: vba ibm-pcomm

最近,我的IBM PCOMM已经在我的工作中升级到12.0.0.1版。从那时起,如果我正在尝试检测空白区域,并且之前已有某些内容,那么当我使用autECLPS.GetText时,即使我看到的所有内容都是黑色的,该文本也会显示出来。我需要一种方法来查看是否有隐藏文本,所以我知道我可以进入下一个程序。我一直在使用autECLPS.GetTextRect来查看我是否可以匹配整个文本块,但这变得乏味。有什么建议吗?

已更新

这是我到目前为止所拥有的:

ElseIf LineCount < 3 Then
    ' If we've gone through less than three lines, we need
    ' to determine if the next line is visible.
    ' ***************************************************************
    ' Due to IBM PCOMM changing their process from actually clearing
    ' screens when going from one to the next to changing the
    ' color of the previous data, there may be some ghost data
    ' present. This code checks to see if any previous data is
    ' hidden from view and determines whether or not to continue.
    ' ***************************************************************
    If SMonth = EMonth Or SMonth <> EMonth And j > 1 And k > 1 Then
        If ScreenName = "MHI" And EditWarnMsg = "E065NO MORE CLMS ON FILE," Then
            Result = objUNET.autECLPS.GetTextRect(SvcLn1, 1, SvcLn3, 80)
            If Left(Result, 2) = POS(j) And Trim(Mid(Result, 4, 6)) = Serv(j) And Trim(Mid(Result, 36, 2)) = RC(j) Then
                Exit Do
             ElseIf Left(Result, 2) = POS(j - 1) And Trim(Mid(Result, 4, 6)) = Serv(j - 1) And Trim(Mid(Result, 36, 2)) = RC(j - 1) Then
                 Exit Do
             ElseIf Left(Result, 2) = POS(j - 2) And Trim(Mid(Result, 4, 6)) = Serv(j - 2) And Trim(Mid(Result, 36, 2)) = RC(j - 2) Then
                  Exit Do
              ElseIf Left(Result, 2) = POS(j - 3) And Trim(Mid(Result, 4, 6)) = Serv(j - 3) And Trim(Mid(Result, 36, 2)) = RC(j - 3) Then
                  Exit Do
              ' If the initial If criteria renders ICN to not have been
              ' found, this will cause a range error. We want to resume
              ' on to the next process if such error occurs.
              On Error Resume Next
              ElseIf Trim(Mid(Result, 165, 10)) = ICN(k) And Trim(Mid(Result, 28, 10)) = Draft(k) Then
                  Exit Do
              ElseIf Trim(Mid(Result, 165, 10)) = ICN(k - 1) And Trim(Mid(Result, 28, 10)) = Draft(k - 1) Then
                  Exit Do
              On Error GoTo 0
              Else
                  GoTo POSBlank
              End If
          End If
      End If
  End If
End If

1 个答案:

答案 0 :(得分:0)

在收到有关人才的建议并进行更多研究后,我已将代码更改为可行的解决方案。它与原版没什么不同,但它更可靠。

If SMonth = EMonth Or SMonth <> EMonth And j > 1 And k > 1 Then
    If ScreenName = "MHI" And EditWarnMsg = "E065NO MORE CLMS ON FILE," Then
        ' Attempt to refresh the connection list
        ' to get current data on the screen.
        objConnMgr.autECLConnList.Refresh
        Result = objUNET.auteclps.GetTextRect(SvcLn1, 1, SvcLn3, 80)
        ' See if we've already processed this place of service
        If Left(Result, 2) = POS(j - 1) Or Left(Result, 2) = POS(j - 2) Or Left(Result, 2) = POS(j - 3) Then
            ' See if we've already processed this service code matching the POS
            If Trim(Mid(Result, 4, 6)) = Serv(j - 1) Or Trim(Mid(Result, 4, 6)) = Serv(j - 2) Or Trim(Mid(Result, 4, 6)) = Serv(j - 3) Then
                ' See if we've already processed this remark code matching the POS and service code
                If Trim(Mid(Result, 36, 2)) = RC(j - 1) Or Trim(Mid(Result, 36, 2)) = RC(j - 2) Or Trim(Mid(Result, 36, 2)) = RC(j - 3) Then
                    ' If start month equals end month, stop the process
                    If SMonth = EMonth Then
                        Exit Do
                    Else
                        GoTo POSBlank  ' Continue process by going to label
                    End If
                End If
            End If
            ' See if we've already processed this ICN
            If Trim(Mid(Result, 165, 10)) = ICN(k - 1) Or Trim(Mid(Result, 165, 10)) = ICN(k - 2) Then
                ' See if we've already processed this draft number matching the ICN
                If Trim(Mid(Result, 28, 10)) = Draft(k - 1) Or Trim(Mid(Result, 28, 10)) = Draft(k - 2) Then
                    If SMonth = EMonth Then
                        Exit Do
                    Else
                        GoTo POSBlank
                    End If
                End If
            End If
        End If
    End If
End If