Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Screen Position
This seemed to work pretty well for me:
Option Explicit Sub testme() Dim myShape As Shape Dim HalfHeight As Double Dim HalfWidth As Double Dim myShapeHeight As Double Dim myShapeWidth As Double myShapeHeight = 72 myShapeWidth = 72 With ActiveWindow.VisibleRange HalfHeight = (.Height / 2) - (myShapeHeight / 2) + .Top HalfWidth = (.Width / 2) - (myShapeWidth / 2) + .Left End With With ActiveSheet Set myShape = .Shapes.AddShape(Type:=msoShapeSmileyFace, _ Top:=HalfHeight, Left:=HalfWidth, _ Width:=myShapeWidth, Height:=myShapeHeight) myShape.Name = "shp" & Format(Now, "yyyymmdd_hhmmss") End With End Sub Ronbo wrote: I am trying to create a routine that will put an autoshape in the middle of the screen/window without using an absolute address. It seems simple but I am not finding anything on it. What I have is; ActiveSheet.Shapes.AddShape(msoShapeSmileyFace, 756.75, 423.75, 72#, 72#). _ Select What I need is to change the absolute address of 756.75, 423.75 to something like ActiveWindow. Select Top.250 Left.250 ActiveSheet.Shapes.AddShape(msoShapeSmileyFace, 72#, 72#) As always any help is appreciated. -- Dave Peterson |
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
Screen Position
Dave:
It's always great to see the response from a question, coming from one of the qurus. Your programming was PERFECT! Thanks a lot for taking the time and sharing your expertise to provide the code. It is truly appreciated. "Dave Peterson" wrote: This seemed to work pretty well for me: Option Explicit Sub testme() Dim myShape As Shape Dim HalfHeight As Double Dim HalfWidth As Double Dim myShapeHeight As Double Dim myShapeWidth As Double myShapeHeight = 72 myShapeWidth = 72 With ActiveWindow.VisibleRange HalfHeight = (.Height / 2) - (myShapeHeight / 2) + .Top HalfWidth = (.Width / 2) - (myShapeWidth / 2) + .Left End With With ActiveSheet Set myShape = .Shapes.AddShape(Type:=msoShapeSmileyFace, _ Top:=HalfHeight, Left:=HalfWidth, _ Width:=myShapeWidth, Height:=myShapeHeight) myShape.Name = "shp" & Format(Now, "yyyymmdd_hhmmss") End With End Sub Ronbo wrote: I am trying to create a routine that will put an autoshape in the middle of the screen/window without using an absolute address. It seems simple but I am not finding anything on it. What I have is; ActiveSheet.Shapes.AddShape(msoShapeSmileyFace, 756.75, 423.75, 72#, 72#). _ Select What I need is to change the absolute address of 756.75, 423.75 to something like ActiveWindow. Select Top.250 Left.250 ActiveSheet.Shapes.AddShape(msoShapeSmileyFace, 72#, 72#) As always any help is appreciated. -- Dave Peterson |
#3
Posted to microsoft.public.excel.programming
|
|||
|
|||
Screen Position
Glad it worked the way you wanted.
Ronbo wrote: Dave: It's always great to see the response from a question, coming from one of the qurus. Your programming was PERFECT! Thanks a lot for taking the time and sharing your expertise to provide the code. It is truly appreciated. "Dave Peterson" wrote: This seemed to work pretty well for me: Option Explicit Sub testme() Dim myShape As Shape Dim HalfHeight As Double Dim HalfWidth As Double Dim myShapeHeight As Double Dim myShapeWidth As Double myShapeHeight = 72 myShapeWidth = 72 With ActiveWindow.VisibleRange HalfHeight = (.Height / 2) - (myShapeHeight / 2) + .Top HalfWidth = (.Width / 2) - (myShapeWidth / 2) + .Left End With With ActiveSheet Set myShape = .Shapes.AddShape(Type:=msoShapeSmileyFace, _ Top:=HalfHeight, Left:=HalfWidth, _ Width:=myShapeWidth, Height:=myShapeHeight) myShape.Name = "shp" & Format(Now, "yyyymmdd_hhmmss") End With End Sub Ronbo wrote: I am trying to create a routine that will put an autoshape in the middle of the screen/window without using an absolute address. It seems simple but I am not finding anything on it. What I have is; ActiveSheet.Shapes.AddShape(msoShapeSmileyFace, 756.75, 423.75, 72#, 72#). _ Select What I need is to change the absolute address of 756.75, 423.75 to something like ActiveWindow. Select Top.250 Left.250 ActiveSheet.Shapes.AddShape(msoShapeSmileyFace, 72#, 72#) As always any help is appreciated. -- Dave Peterson -- Dave Peterson |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Can I fix the position of an object on the screen? | Excel Discussion (Misc queries) | |||
screen position indication? | Excel Discussion (Misc queries) | |||
Position of CellCursor on Screen (absolute position) | Excel Programming | |||
MsgBox Screen Position | Excel Programming | |||
InputBox Screen Position | Excel Programming |