A Microsoft Office (Excel, Word) forum. OfficeFrustration

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.

Go Back   Home » OfficeFrustration forum » Microsoft Powerpoint, Publisher and Visio » Visio
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Need Help with Grid Origin Macro I wrote



 
 
Thread Tools Display Modes
  #1  
Old May 25th, 2010, 06:58 PM posted to microsoft.public.visio.general
CalgaryBob
external usenet poster
 
Posts: 6
Default 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  
Old May 26th, 2010, 03:03 PM posted to microsoft.public.visio.general
Paul Herber[_2_]
external usenet poster
 
Posts: 17
Default 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  
Old May 27th, 2010, 11:01 PM posted to microsoft.public.visio.general
CalgaryBob
external usenet poster
 
Posts: 6
Default 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  
Old May 28th, 2010, 12:52 AM posted to microsoft.public.visio.general
Paul Herber[_2_]
external usenet poster
 
Posts: 17
Default 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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 06:09 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.