fitzmorrispr
New Member
- Joined
- Sep 6, 2024
- Messages
- 4
- Office Version
- 365
- Platform
- Windows
Hello
I have followed @Jaafar Tribak 's excellent work in Display Userform in TaskBar with custom Icon and Hide Excel (mimicking a standalone application) to make a userform that appears as a standalone application. It's connected to an instance of SolidWorks through its VBA api. By running the workbook that contains it with the /x, /s, /r and /e switches, the form doesn't get in the way of normal use of excel.
I show the userform in my Workbook_Open sub. I am ashamed to admit that at first, I used Resume Next and a loop that ends when err.number = 0 to show the form, having forgotten about load statements.
The problem:
My userform disappears into the shuffle of windows as I work with browser windows, and though it's easy enough to bring it back to the top with its taskbar button, the point of it is to be in easy reach whenever SolidWorks has focus, serving as a floating toolbar.
I thought I might be able to get it to tie itself to SolidWorks through the windows api using SetParent, and there were no errors when I tried, but the userform window became completely invisible. (incidentally, the hwnd for SolidWorks was obtained from its API, so calling the SetParent function was trivial)
Unfortunately, I have lost the code I had added but it was literally just a Private Declare and a Call.
I suspect that the problem was perhaps partly a result of the window styles and extended window styles that are set on a UserForm window, but I suppose it could be something Solidworks did.
I've been working in Excel for this because the VBE built into the rather old copy of SolidWorks I'm provided with causes it to crash whenever a macro is run from inside it. External macros work perfectly, however. This is due to an incompatibility between Office 365 and SolidWorks 2013, as the problem never occurred when we had Office 2016
I have made some progress on my research into this, and I'm feel I could trial and error my way to a working solution, but I figured I should not be going solo on this
presently, the styles set on my userform are:
I have followed @Jaafar Tribak 's excellent work in Display Userform in TaskBar with custom Icon and Hide Excel (mimicking a standalone application) to make a userform that appears as a standalone application. It's connected to an instance of SolidWorks through its VBA api. By running the workbook that contains it with the /x, /s, /r and /e switches, the form doesn't get in the way of normal use of excel.
I show the userform in my Workbook_Open sub. I am ashamed to admit that at first, I used Resume Next and a loop that ends when err.number = 0 to show the form, having forgotten about load statements.
The problem:
My userform disappears into the shuffle of windows as I work with browser windows, and though it's easy enough to bring it back to the top with its taskbar button, the point of it is to be in easy reach whenever SolidWorks has focus, serving as a floating toolbar.
I thought I might be able to get it to tie itself to SolidWorks through the windows api using SetParent, and there were no errors when I tried, but the userform window became completely invisible. (incidentally, the hwnd for SolidWorks was obtained from its API, so calling the SetParent function was trivial)
Unfortunately, I have lost the code I had added but it was literally just a Private Declare and a Call.
I suspect that the problem was perhaps partly a result of the window styles and extended window styles that are set on a UserForm window, but I suppose it could be something Solidworks did.
I've been working in Excel for this because the VBE built into the rather old copy of SolidWorks I'm provided with causes it to crash whenever a macro is run from inside it. External macros work perfectly, however. This is due to an incompatibility between Office 365 and SolidWorks 2013, as the problem never occurred when we had Office 2016
I have made some progress on my research into this, and I'm feel I could trial and error my way to a working solution, but I figured I should not be going solo on this
presently, the styles set on my userform are:
Code:
WS_BORDER, WS_CAPTION, WS_CLIPSIBLINGS, WS_DLGFRAME, WS_GROUP, WS_MINIMIZEBOX, WS_OVERLAPPED, WS_SYSMENU, WS_TILED, WS_VISIBLE, WS_EX_DLGMODALFRAME, WS_EX_LEFT, WS_EX_LTRREADING, WS_EX_RIGHTSCROLLBAR, WS_EX_WINDOWEDGE,