Is there an API Declaration that I can call via VBA to lock the position of the toolbars?
Printable View
Is there an API Declaration that I can call via VBA to lock the position of the toolbars?
Most likely not, the Office toolbars are a custom control and there is no standard "lock position" message that I am aware of.
You could try your luck in the Office Development forum. Make sure you post what version of Office you're using.
Welcome to the forums.
Sorry i didnt mention the specific application. Im working in VBA for Autocad, and I wish to lock those toolbars that i accidentally move while I work. I already posted in AutoCAD's forum but they suggested to download some 3rd party application to lock these toolbars. But I want to lock it without loading 3rd party apps. If there's a thing like that, I thought that maybe there's an API call that I can use. just guessing.
I'll try posting in Office Development. I hope VBA for other applications posts are also welcome in that thread. Thanks.
Ah, well that might be different, I'm not sure how AutoCAD's toolbars work, they are most likely different to Office's.
You may want to try something like this but modify for AutoCads VBA but they should be compaitble.
You will need to change it to reflect the toolbar name you want to lock.VB Code:
Dim oCB As Office.CommandBar Set oCB = Application.CommandBars.Item("Standard") oCB.Protection = msoBarNoChangeDock Or msoBarNoMove Or msoBarNoCustomize
VBA is licensed from MS and should include the Office reference or similar.
Yes, in fact the VBA interface are the same.
I loaded the MS Office 11 type library to have access for that Command Bar object and tried to set it to AutoCAD applications toolbar (coz AutoCAD doesn't have command bars) but I've got the 'type mismatch' error. Maybe because in MS Office its a Command Bar (custom control-as posted) and not a standard toolbar.
Hmm, then try using MS Spy++ and see what the toolbars window class name is. Once you have that you can declare your objects as that type and should get you farther.
Yes, to be licensed to integrate VBA IDE into an application you need to pay some decent $'s and you may have commandbars for the VBA IDE but will be different for AutoCads GUI.
I use EliteSpy and these are the results.
Window Handle: 2163946
Window Caption:
Window Class: ToolbarWindow32
Window Style: WS_CHILD WS_CLIPSIBLINGS WS_VISIBLE
Rectangle: (374, 73) - (853, 102)
Parent Handle: 2229562
Parent Caption: AutoCAD Tools
Parent Class: AfxWnd70
Test made on one of the toolbars. In fact I can enable, disable, show and hide, by EliteSpy. But to lock, there is none.