Forum

Can help me to run ...
 
Notifications
Clear all

Can help me to run this userform on 64 bit Office

11 Posts
3 Users
0 Reactions
148 Views
(@ivayleto)
Posts: 5
Active Member
Topic starter
 
Need help this to be work on 32 bit and 64 bit office. It is menus in userform. For now it work on 32 bit, but I want to work an on 64 bit, can someone help me to fix it. The problem is when I click on "Show Api Menu" - userfom is appear, but whet I choose any of menus ex: File->NewTask nothing happen.Thank you!
 
Posted : 25/02/2022 11:14 am
(@catalinb)
Posts: 1937
Member Admin
 

Hi Ivaylo,

The form does not load on my side, this line errors out:

g_lpMyWndProc = SetWindowLong(g_hForm, GWL_WNDPROC, AddressOf HookWinProc) (a data type mismatch error)

That mismatch should be fixed by changing the data type of the arguments for the failing procedure, the form loads now.

I changed this function, the part in red:

Public Declare PtrSafe Function SetWindowLong _
Lib "user32" _
Alias "SetWindowLongA" ( _
ByVal hwnd As Long, _
ByVal nIndex As Long, _
ByVal dwNewLong As LongPtr) _
As Long

 
Posted : 01/03/2022 2:33 am
(@debaser)
Posts: 836
Member Moderator
 

hWnd should also be LongPtr in that code as it's a handle.

 
Posted : 01/03/2022 4:59 am
(@ivayleto)
Posts: 5
Active Member
Topic starter
 

I make it like you say. The form is appear, but when I try ti choose command nothing happen. Do you know Why?

 
Posted : 01/03/2022 7:32 am
(@catalinb)
Posts: 1937
Member Admin
 

Is there a reason for using this menu in a userform?

You have much better options, you can build a custom menu in ribbon, even in runtime if a dynamic menu is needed.

Will work in a Mac as well, not limited to windows as the current code is.

See: https://docs.microsoft.com/en-us/openspecs/office_standards/ms-customui/d842006e-3187-4f66-a17d-0819a3cc94b5

The available controls can be found in: https://interoperability.blob.core.windows.net/files/MS-CUSTOMUI2/%5bMS-CUSTOMUI2%5d.pdf

 
Posted : 01/03/2022 9:30 am
(@ivayleto)
Posts: 5
Active Member
Topic starter
 

I need some like this. 

 

Screenshot-2022-03-01-173204.png

 
Posted : 02/03/2022 11:37 am
(@catalinb)
Posts: 1937
Member Admin
 

Screenshot-2022-03-01-190824-1.pngOk, those macros that are called needs to be called only from the form?

They can be called from ribbon, not seeing any reason to use them only in form.

The custom ribbon can be created only for a specific file, but if you want it to show up on every excel file, you have to create the menu on an addin.

See image attached for a custom ribbon.

 
Posted : 02/03/2022 1:11 pm
(@debaser)
Posts: 836
Member Moderator
 

This should work on 64bit.

 
Posted : 03/03/2022 6:14 am
(@ivayleto)
Posts: 5
Active Member
Topic starter
 

Thank you it worked but if I want to show another userform and hide menu userform it is bug and close again can I make to show another userform by clicking on menu? Can you tell me how? click on "ShellRun" like example.1-1.PNG2-1.PNG3-1.png4-1.PNG5-1.PNG

 
Posted : 08/03/2022 5:38 am
(@debaser)
Posts: 836
Member Moderator
 

Try moving the code back to the Initialize event, as in the attached version.

 
Posted : 08/03/2022 2:46 pm
(@ivayleto)
Posts: 5
Active Member
Topic starter
 

Thank you very much! It working how I expect. Thanks again.

 
Posted : 10/03/2022 1:27 pm
Share: