Using SendMessage or PostMessage

azizrasul

Well-known Member
Joined
Jul 7, 2003
Messages
1,304
Office Version
  1. 365
  2. 2019
  3. 2016
Platform
  1. Windows
I want to press the keys ALT+R on a Password dialog box of another Excel file either using SendMessage or PostMessage. I have the library functions.
Also any help in entering keystrokes to enter the password in the text box of the Password dialog box would also be useful.
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
To add information, I have a Password dialog box with a Password: textbox, a visible 'Read Only' button, an invisible 'OK' button and a visible 'Cancel' button. I want to press the 'Read Only' button.

I have worked out how to get the window handle which gives me a value i.e.

Code:
hWnd = FindWindow(vbNullString, "Password")

I guess I need to use the FindWindowEx function to somehow obtain the handle of the 'Read Only' button but I don't know how to do this. I've tried this but it isn't giving me a value.

Code:
iHwndChild = FindWindowEx(hWnd, 0&, "Button", vbNullString)

I know I may have to use

Code:
Call SendMessage(iHwndChild, BM_CLICK, 0, 0)

When I run these lines of code nothing happens. Any ideas anyone?
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,854
Members
449,051
Latest member
excelquestion515

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