Use of PostMessage with Excel

Get help with using AutoHotkey (v1.1 and older) and its commands and hotkeys
Nicolas25
Posts: 39
Joined: 22 Oct 2021, 09:17

Use of PostMessage with Excel

Post by Nicolas25 » 29 Nov 2021, 11:47

Hello,

I use the following program to have access to the Menus of the notepad ((Bloc-notes in french).

Code: Select all

SetTitleMatchMode, 2
!a::
PostMessage, 0x0111, 33, 0, , Bloc-notes
When I change (by trying) the 33 by other numbers, I manage to find all the possibilities of all the menus of the Notepad.

I try to make the same with Excel (by changing the number 51 by other numbers) - but in this case nothing happen:

Code: Select all

SetTitleMatchMode, 2
!a::
PostMessage, 0x0111, 51, 0, , "ahk_class XLMAIN"
Do you have an idea if PostMessage work or not with Excel ? If yes, is it possible to find on internet a list with all this possibilities ?

Thank you very much in advance for your help,

Best regards,

Nicolas.[/b]

gregster
Posts: 9021
Joined: 30 Sep 2013, 06:48

Re: Use of PostMessage with Excel

Post by gregster » 29 Nov 2021, 15:03

At least, you shouldn't put quotes around ahk_class XLMAIN - in this case, it is not an expression.
I doubt if this is enough - but with quotes it will never work.

User avatar
flyingDman
Posts: 2817
Joined: 29 Sep 2013, 19:01

Re: Use of PostMessage with Excel

Post by flyingDman » 29 Nov 2021, 15:23

This appears to be a purely academic exercise as COM is likely to be able to handle everything that you would be able to do pushing buttons in the ribbon (and more). Could you give an example of the things you want to do?
See here for Excel COM tutorials:
https://autohotkey.com/board/topic/69033-basic-ahk-l-com-tutorial-for-excel/
viewtopic.php?f=7&t=8978
viewtopic.php?f=6&t=77#p495
https://docs.microsoft.com/en-us/office/vba/api/overview/excel
https://github.com/ahkon/MS-Office-COM-Basics/tree/master/Examples/Excel
14.3 & 1.3.7

Nicolas25
Posts: 39
Joined: 22 Oct 2021, 09:17

Re: Use of PostMessage with Excel

Post by Nicolas25 » 30 Nov 2021, 10:03

Thank you gregster concerning your remarks about the quotes. In fact, when I made the test, I did'nt put the quotes (but I write it again for this site, I add the quotes by mistakes).

Best regards,

Nicolas.

Nicolas25
Posts: 39
Joined: 22 Oct 2021, 09:17

Re: Use of PostMessage with Excel

Post by Nicolas25 » 30 Nov 2021, 10:12

Dear flyingDman,

Thank you very much for all the links that you send me. I begin to read it, and it will probably give me the possibility to do all what I want. In fact, if I undertand good the COM give the possibility to use all the possibilities of the programmation with VBA for application.

It's sure that in this case, my question was a purely academic exercice.

But in any case, it's interresting to know if a list of Message exist or not for Excel to use in:

Code: Select all

PostMessage, 0x0111, 51, 0, , ahk_class XLMAIN

If somebody has an idea ?

In some case, it can be perhaps more quick to put direct the good number in place of the 51 and to have access directly to the good Menu.

Best regards,

Nicolas.

Post Reply

Return to “Ask for Help (v1)”