Can not get data from Edit Box of Formula Bar

hoangvn79

New Member
Joined
Feb 1, 2010
Messages
8
Dear: everyone! I want to retrieve data as the data string length in the Formula Bar (the formula bar, rather from its Edit Box) I have used the following
1. Declare Private Declare Function FindWindow Lib "user32" Alias ​​"FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long
Private Declare Function FindWindowEx Lib "user32" Alias ​​"FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long
Private Declare Function GetWindowTextLength Lib "user32" Alias ​​"GetWindowTextLengthA" (ByVal hwnd As Long) As Long
Declare Function GetWindowText Lib "user32" Alias ​​"GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
Declare Function SendMessage Lib "user32" Alias ​​"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Public Const WM_GETTEXTLENGTH = & HE Public Const C_EXCEL_WINDOW = "XLMAIN" Public Const C_EXCEL_EDITBOX = "EXCEL <" Take the handle of the Formula Bar

Public Function hWndEditbox () As Long
Dim hWndMain As Long
HWndMain = FindWindow(C_EXCEL_WINDOW, Application.Caption)

HWndEditbox = FindWindowEx (hWndMain, ByVal 0 &, C_EXCEL_EDITBOX, vbNullString) End Function
3. Get the length of the data string in the formula With 03 ways Way
1 MsgBox SendMessage (hWndEditbox, WM_GETTEXTLENGTH, ByVal 0 &, ByVal 0 &)
2 mystr = String (255, Chr $ (0))
MsgBox GetWindowText (hWndEditbox, mystr, Len (mystr))
MsgBox GetWindowTextLength(hWndEditbox)
Yet the result is always 0 (although there are still data in the Formula Bar) So please ask people to answer help why and how to fix
 
Last edited:

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!

Forum statistics

Threads
1,223,711
Messages
6,174,029
Members
452,542
Latest member
Bricklin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top