If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Need Help with Grid Origin Macro I wrote
Hi All,
I have written a macro to set the Grid Origin (Either Vertical or Horizontal) to the X-Position or Y-Position of a selected Shape. It works well if the selected Shape is of the type that uses only a single X and Y Co-ordinate, but if I try to run the macro when the selected shape uses Begin X, End X and Begin Y, End Y Co-ordinates, I get an error, and a pop-up to allow debugging of the macro. This in itself is not a problem, but the Undo command no longer works after the error is encountered, the only way to get Undo to work is to close the Visio App. The macros I'm using are shown below, I'm hoping someone could show me how to modify the nacro to avoid the error by using some sort of error checking" MACROS: Sub Guide_Set_Vertical() ' Keyboard Shortcut: Ctrl+Shift+X ' Dim UndoScopeID1 As Long UndoScopeID1 = Application.BeginUndoScope("Ruler & Grid") Dim vsoShape1 As Shape Set vsoShape1 = Application.ActiveWindow.Page.PageSheet 'ID = Application.ActiveWindow.Selection.Item(1). temporigin = Application.ActiveWindow.Selection.Item(1).CellsSR C(visSectionObject, visRowXFormOut, visXFormPinX).FormulaU vsoShape1.CellsSRC(visSectionObject, visRowRulerGrid, visXGridOrigin).FormulaU = temporigin Application.EndUndoScope UndoScopeID1, True End Sub Sub Guide_Set_Horizontal() ' Keyboard Shortcut: Ctrl+Shift+Y ' Dim UndoScopeID1 As Long UndoScopeID1 = Application.BeginUndoScope("Ruler & Grid") Dim vsoShape1 As Shape Set vsoShape1 = Application.ActiveWindow.Page.PageSheet 'ID = Application.ActiveWindow.Selection.Item(1). temporigin = Application.ActiveWindow.Selection.Item(1).CellsSR C(visSectionObject, visRowXFormOut, visXFormPinY).FormulaU vsoShape1.CellsSRC(visSectionObject, visRowRulerGrid, visYGridOrigin).FormulaU = temporigin Application.EndUndoScope UndoScopeID1, True End Sub Sub GridOnOff() ' Keyboard Shortcut: Ctrl+g ' Application.ActiveWindow.ShowGrid = Not Application.ActiveWindow.ShowGrid Application.ActiveWindow.ShowGuides = Not Application.ActiveWindow.ShowGuides End Sub |
#2
|
|||
|
|||
Need Help with Grid Origin Macro I wrote
On Tue, 25 May 2010 10:58:01 -0700, CalgaryBob
wrote: Hi All, I have written a macro to set the Grid Origin (Either Vertical or Horizontal) to the X-Position or Y-Position of a selected Shape. It works well if the selected Shape is of the type that uses only a single X and Y Co-ordinate, but if I try to run the macro when the selected shape uses Begin X, End X and Begin Y, End Y Co-ordinates, I get an error, and a pop-up to allow debugging of the macro. Rather than allow an error to occur you could check whether the cell exists using the CellExists property on the BeginY cell: http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx or use the OneD propery to dertmine whether it is a 1D or 2D shape. -- Regards, Paul Herber, Sandrila Ltd. Electronics for Visio http://www.sandrila.co.uk/visio-electronics/ Electrical for Visio http://www.sandrila.co.uk/visio-electrical/ Electronics Packages for Visio http://www.sandrila.co.uk/visio-electronics-packages/ |
#3
|
|||
|
|||
Need Help with Grid Origin Macro I wrote
"Paul Herber" wrote: Rather than allow an error to occur you could check whether the cell exists using the CellExists property on the BeginY cell: http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx or use the OneD propery to dertmine whether it is a 1D or 2D shape. -- Regards, Paul Herber, Sandrila Ltd. Electronics for Visio http://www.sandrila.co.uk/visio-electronics/ Electrical for Visio http://www.sandrila.co.uk/visio-electrical/ Electronics Packages for Visio http://www.sandrila.co.uk/visio-electronics-packages/ . Thank You Very much Paul, your response helped me get the problem solved. You are a great asset to this forum! |
#4
|
|||
|
|||
Need Help with Grid Origin Macro I wrote
On Thu, 27 May 2010 15:01:09 -0700, CalgaryBob
wrote: "Paul Herber" wrote: Rather than allow an error to occur you could check whether the cell exists using the CellExists property on the BeginY cell: http://msdn.microsoft.com/en-us/libr...ice.11%29.aspx or use the OneD propery to dertmine whether it is a 1D or 2D shape. Thank You Very much Paul, your response helped me get the problem solved. You are a great asset to this forum! Thank you for your kind words. CalgaryBob! -- Regards, Paul Herber, Sandrila Ltd. Electronics for Visio http://www.sandrila.co.uk/visio-electronics/ Electrical for Visio http://www.sandrila.co.uk/visio-electrical/ Electronics Packages for Visio http://www.sandrila.co.uk/visio-electronics-packages/ |
Thread Tools | |
Display Modes | |
|
|