ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   switch on 'snap to' from vba (https://www.excelbanter.com/excel-programming/301805-switch-snap-vba.html)

jngi[_2_]

switch on 'snap to' from vba
 
Does anyone out there know how to switch on the 'snap to grid' - drawing tools - using VBA? When I record a macro no code appears for this. I've tried 'msoSnapToGrid' etc etc.

Tom Ogilvy

switch on 'snap to' from vba
 
Sub Macro4()
Dim btn As CommandBarButton
Set btn = CommandBars("Drawing").FindControl(ID:=549, Recursive:=True)
btn.Execute
End Sub

--
Regards,
Tom Ogilvy

"jngi" wrote in message
...
Does anyone out there know how to switch on the 'snap to grid' - drawing

tools - using VBA? When I record a macro no code appears for this. I've
tried 'msoSnapToGrid' etc etc.



Tom Lavedas

switch on 'snap to' from vba
 
I knew it was done through the CommandBars object, but it's so far down in the menu tree that it took some digging to find ...

Set cb = CommandBars("Drawing").Controls(1).CommandBar.Cont rols(5)_
.CommandBar.Controls(1)
if Not (cb.State = msoButtonDown) Then cb.Execute

Tom Lavedas
===========

"jngi" wrote:

Does anyone out there know how to switch on the 'snap to grid' - drawing tools - using VBA? When I record a macro no code appears for this. I've tried 'msoSnapToGrid' etc etc.


Tom Lavedas

switch on 'snap to' from vba
 
I knew it was done through the CommandBars object, but it's so far down in the menu tree that it took some digging to find ...

Set cb = CommandBars("Drawing").Controls(1).CommandBar.Cont rols(5)_
.CommandBar.Controls(1)
if Not (cb.State = msoButtonDown) Then cb.Execute

Tom Lavedas
===========


"jngi" wrote:

Does anyone out there know how to switch on the 'snap to grid' - drawing tools - using VBA? When I record a macro no code appears for this. I've tried 'msoSnapToGrid' etc etc.



All times are GMT +1. The time now is 04:34 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com