Ask Question Forum:
Model Library:2025-02-08:A.I. model is online auto reply
C
O
M
P
U
T
E
R
2
8
Show
#
ASK
RECENT
←
- Underline
- Bold
- Italic
- Indent
- Step
- Bullet
- Quote
- Cut
- Copy
- Paste
- Table
- Spelling
- Find & Replace
- Undo
- Redo
- Link
- Attach
- Clear
- Code
Below area will not be traslated by Google,you can input code or other languages
Hint:If find spelling error, You need to correct it,1 by 1 or ignore it (code area won't be checked).
X-position of the mouse cursor
Y-position of the mouse cursor
Y-position of the mouse cursor
Testcursor
caretPos
Attachment:===
Asked by duncanb7
at 2024-07-13 11:26:54
Point:500 Replies:5 POST_ID:828513USER_ID:11059
Topic:
Visual Basic Programming;Microsoft Office Suite;Miscellaneous Programming
I have one VBA program with 2003 Excel which is working successfully in one
of my Window XP computer. But when I try to run it on my other
Window XP computer that is not working at all since I found it never pass one
do loop statement like as follows , the loop is for deleteing all
IE browser windows before running other part of program, and all IE window handle is found
by findwindow() API function.
When I'm debugging it step by step with F8 function key and going to findwindow() code area that is working and window handle id is okay and matched to the target opening IE browser window
But when going to SendMessageString code, it never report any bug or error by VBA, and it can NOT
close the IE window broswer with hdlg ,window ID.
I don't know why it doesn't work on the second WIndow XP computer but it works
fine on the first computer both computer are installed with same IE and WIndow XP system(SP3 profession one computer and home edition version on the other)
and same 2003 MS office(excel)
The only message I can have when the SendMessageString code is running, it would sound one loud beep sound or tone on my speaker. So I suspect it is error , and other API function in my
program is working and never have beep sound on my speaker when it is running.
Please advise any suggestion
Other alternative for SendMessageString to close IE window in API function ?
Duncan
API function of SendMessageString is not working on the following code===================================================Private Declare Function SendMessageSTRING Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As String) As LongPrivate Const WM_CLOSE = &H10Dim hdlg as longDo until hdlg=0hdlg=Findwindow("IEframe",vbNullString)debug.print hex(hdlg)SendMessageString hdlg, WM_CLOSE,0,0Loop 1:2:3:4:5:6:7:8:9:10:11:
Author: duncanb7 replied at 2024-07-14 03:13:12
after I uninstall IE7 and re-install IE7 on the second computer.
The Sendmessage API function
is working back as the first one.
Thanks for your triggering
Duncan
The Sendmessage API function
is working back as the first one.
Thanks for your triggering
Duncan
Accepted Solution
Expert: GeoffHarper replied at 2024-07-13 12:01:48
500 points GOOD
I would try the following on two machines to see if it works the same:
' DeclaresPrivate Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As LongPrivate Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As LongPrivate Const WM_CLOSE = &H10' Code to insert wherever you have itDim hdlg as longhdlg = 1Do until hdlg = 0 hdlg = Findwindow("IEframe", vbNullString) Debug.Print Hex(hdlg) If hdlg <> 0 Then SendMessage hdlg, WM_CLOSE, 0, 0Loop 1:2:3:4:5:6:7:8:9:10:11:12:13:14:15:
Author: duncanb7 replied at 2024-07-13 11:45:02
WHen I step into SendMessageString by F8 key, my speaker will
have one screaming sound, beep, tone , it seems it has error
but VBA editor could not show the message or warning to me
have one screaming sound, beep, tone , it seems it has error
but VBA editor could not show the message or warning to me
Author: duncanb7 replied at 2024-07-13 11:42:47
it is already set hdlg=1 but sorry forget to tell
and it could go into the loop by F8 key
Dim hdlg as long
hdlg=1
Do until hdlg=0
hdlg=Findwindow("IEframe",vbNullString)
debug.print hex(hdlg)
and it could go into the loop by F8 key
Dim hdlg as long
hdlg=1
Do until hdlg=0
hdlg=Findwindow("IEframe",vbNullString)
debug.print hex(hdlg)
Expert: GeoffHarper replied at 2024-07-13 11:40:10
In-between these two lines:
Dim hdlg as long
Do until hdlg=0
Add another line:
hdlg=1
Dim hdlg as long
Do until hdlg=0
Add another line:
hdlg=1