Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/26.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/vba/15.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/bash/18.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Excel VBA。从其他应用程序检索文本_Excel_Vba - Fatal编程技术网

Excel VBA。从其他应用程序检索文本

Excel VBA。从其他应用程序检索文本,excel,vba,Excel,Vba,我试图从另一个应用程序中检索文本,只返回3个空格。 (这一点受到了强烈的启发) Ret=FindWindow(vbNullString,“koelskerN-R1Q2 b4449(端口27910)”) 如果Ret为0,则 ChildRet=FindWindowEx(Ret,ByVal 0&,“编辑”,vbNullString) strBuff=String(GetWindowTextLength(ChildRet)+1,Chr$(0)) GetWindowText ChildRet、strBuf

我试图从另一个应用程序中检索文本,只返回3个空格。 (这一点受到了强烈的启发)

Ret=FindWindow(vbNullString,“koelskerN-R1Q2 b4449(端口27910)”)
如果Ret为0,则
ChildRet=FindWindowEx(Ret,ByVal 0&,“编辑”,vbNullString)
strBuff=String(GetWindowTextLength(ChildRet)+1,Chr$(0))
GetWindowText ChildRet、strBuff、Len(strBuff)
ButCap=strBuff
debug.print strBuff'刚刚返回3。(空格)
如果结束

Ret返回值=8062086 ChildRet返回值=9309970


我以前没有真正尝试过使用FindWindow,所以我希望能得到一些关于如何从类中提取文本和编辑类的指导。

我发现,应用程序有一个日志文件1,它将所有内容提取到一个.txt文件。这个问题解决了。

使用@SiddharthRout示例,您可以单击此编辑框,然后只需将
SendKeys
复制到
剪贴板中的文本,然后从内存中读取。
Ret = FindWindow(vbNullString, "koelskerN - R1Q2 b4449 (port 27910)")

If Ret <> 0 Then
    ChildRet = FindWindowEx(Ret, ByVal 0&, "Edit", vbNullString)

    strBuff = String(GetWindowTextLength(ChildRet) + 1, Chr$(0))
    GetWindowText ChildRet, strBuff, Len(strBuff)
    ButCap = strBuff

    debug.print strBuff 'Is just returning 3. blank spaces)
End If