473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

API Function FindWindowEx works on my PC but not end user

Hello,

I am running the code below in an Excell '03 userform, the purpose of the code is to set the form as a child of the workbook so it moves around with it etc. however the last call to the FindWindowEx function only works on my PC when run but not on my end-user's. The frustrating part is that the first call to the function runs fine but not the second. Hopefully someone with more experience using API's may have an answer to this since I'm completely stumped. On a side note, another developer in my office is also able to run the code successfully. Would there be a problem with the fact that the end-user's version of the workbook is being opened as Read-Only? Any help would be much appreciated.

Expand|Select|Wrap|Line Numbers
  1. Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" _
  2.     (ByVal hWnd1 As Long, _
  3.     ByVal hWnd2 As Long, _
  4.     ByVal lpsz1 As String, _
  5.     ByVal lpsz2 As String) As Long
  6.  
  7. Private Sub UserForm_Initialize()
  8. AppHWnd = Application.hwnd
  9. If AppHWnd > 0 Then
  10.     ' get the window handle of the Excel desktop
  11.     DeskHWnd = FindWindowEx(AppHWnd, 0, "XLDESK", vbNullString)
  12.     If DeskHWnd > 0 Then
  13.         ' get the window handle of the ActiveWindow
  14.         WindowHWnd = FindWindowEx(DeskHWnd, 0, "EXCEL7", ActiveWindow.Caption)
  15. ...
  16. End Sub
  17.  
Feb 12 '08 #1
1 2570
kadghar
1,295 Expert 1GB
Hello,
(...)
Would there be a problem with the fact that the end-user's version of the workbook is being opened as Read-Only? Any help would be much appreciated.

Expand|Select|Wrap|Line Numbers
  1. '(...)
  2.         ' get the window handle of the ActiveWindow
  3.         WindowHWnd = FindWindowEx(DeskHWnd, 0, "EXCEL7", ActiveWindow.Caption)
  4. ...
  5. End Sub
  6.  
Yes, it's because it's Read-Only:

When you ask for its name to be ActiveWindow.Caption, that'll be the name of the VBA window, that doesn't have the [Read-Only] tag but the Excel application does. If you have no other workbooks open in that excel, you can have the code search for vbnullstring instead.

HTH
Feb 13 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: cheezebeetle | last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when...
1
by: enahar | last post by:
Hello, i want to find out how many instances of a form (say childForm1) is running using FindWindowEx but value return is always zero by this method. What wrong I am doing it..Can anybody...
4
by: Simon Matthews | last post by:
Hi, I'm trying to find a window handle using FindWindowEx. I get an error undecalred identifier if I use FindWindowEx() and not a member of global namespace if I use ::FindWindowEx()... Even...
0
by: Simon Matthews | last post by:
I am trying to find a window handle using FindWindowEx, yet when I compile the code I get an "unresolved identifier" error, usinf ::FindWindowEx() gives me the error "not a member of global...
1
by: phx | last post by:
In order to use "sendMessage" of "findwindowex" functions , think "user32.lib" must be declared. but In vb.net , i can only reference .dll 's. how am i going to user these functions , or similer...
7
by: Lars Netzel | last post by:
Do I use FindWindowEx() to find control ( a button.. ) within a Window or is that only to find child Windows after using FindWindows() best regards /Lars
1
by: darkchild50 | last post by:
is it possible to loop through all top level windows with GetWindowEx(), and save all their handles in an array? i have been trying this one for a while but it dosent seem to work i end up in a...
1
by: Geky | last post by:
HWND window = ::FindWindow(NULL,"Internet connect"); while(window == NULL) { window = ::FindWindow(NULL,"Internet connect"); } HWND general = ::FindWindowEx(window,0,"General",NULL); I...
6
by: kru | last post by:
Hi All, I've been trying to get FindWindowEx to work to locate a button, and am stumped on the following: The structure of the external app is as so from Spy++: - "Main Window" -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.