What is it that you are after? There may be simpler ways to achieve that.
- Chirag
PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
"jm.almeras" <jm.al...@nospam.niet> wrote in message
news:uc$NHvcoK...@TK2MSFTNGP06.phx.gbl...
The reasons behind my question is the following : I work day long with
Powerpoint, and i have progressively built a lot of vba programs to assist
me in my work. Example : i have various buttons to add different objects on
the slide on which i am working (textbox, legend, images...). Now if i am
working with a zoom factor on a portion of the slide, i wish to add the new
object on the center of the portion of the slide being displayed. I have a
button that will enlarge the screen around the objects currently selected
and another button that will do the reverse (step forward / step backward)
and for that i also need to know precisely the current slide portion.
Thank you for your help
Jean-Marie
"Chirag" <Chi...@discussions.microsoft.com> a �crit dans le message de
news:OLAPeljo...@TK2MSFTNGP02.phx.gbl...
I use GetCursorPos Lib "user32" to get the mouse cursor position in pixels.
Then I use the PixelsToPoints function in Word 11.0 Object Library so that I
can convert the mouse cursor position to points. I have to scale the
resulting value to account for the zoom size of the slide and apply an offset
to account for the edge of the slide relative to the screen origin. Here is
my code. It works as long as I am using a monitor with 1280 by 800
resolution and have the slide centers and zoomed at 65%.
Private Type POINTAPI
X As Long
Y As Long
End Type
Private Declare Function GetCursorPos Lib "user32" _
(lpPoint As POINTAPI) As Long
Public Function GetXCursorPos() As Long
Dim pt As POINTAPI
GetCursorPos pt
GetXCursorPos = pt.X
End Function
Public Function GetYCursorPos() As Long
Dim pt As POINTAPI
GetCursorPos pt
GetYCursorPos = pt.Y
End Function
Public Sub DropXMacro()
Dim MouseCursorPosX As Long
Dim MouseCursorPosY As Long
If ((PixelsToPoints(GetXCursorPos(), False) / (ActiveWindow.View.Zoom /
100)) - 355) < 0 Then
MouseCursorPosX = 0
ElseIf ((PixelsToPoints(GetXCursorPos(), False) /
(ActiveWindow.View.Zoom / 100)) - 355) > 720 Then
MouseCursorPosX = 720
Else
MouseCursorPosX = (PixelsToPoints(GetXCursorPos(), False) /
(ActiveWindow.View.Zoom / 100)) - 355
End If
If ((PixelsToPoints(GetYCursorPos(), True) / (ActiveWindow.View.Zoom /
100)) - 226) < 0 Then
MouseCursorPosY = 0
ElseIf ((PixelsToPoints(GetYCursorPos(), True) / (ActiveWindow.View.Zoom
/ 100)) - 226) > 540 Then
MouseCursorPosY = 540
Else
MouseCursorPosY = (PixelsToPoints(GetYCursorPos(), True) /
(ActiveWindow.View.Zoom / 100)) - 226
End If
ActiveWindow.Selection.SlideRange.Shapes.AddTextbox(msoTextOrientationHorizontal, MouseCursorPosX, MouseCursorPosY, 40, 23).Select
ActiveWindow.Selection.TextRange.Text = "X"
End Sub
"jm.almeras" wrote:
> Hi Chirag, thank you for the tips, however i must say i am not a windows API
> expert. If you could tell me the api function names to call, starting from
> that i might be able to find my way to the solution.
>
> The reasons behind my question is the following : I work day long with
> Powerpoint, and i have progressively built a lot of vba programs to assist
> me in my work. Example : i have various buttons to add different objects on
> the slide on which i am working (textbox, legend, images...). Now if i am
> working with a zoom factor on a portion of the slide, i wish to add the new
> object on the center of the portion of the slide being displayed. I have a
> button that will enlarge the screen around the objects currently selected
> and another button that will do the reverse (step forward / step backward)
> and for that i also need to know precisely the current slide portion.
>
> Thank you for your help
>
> Jean-Marie
>
>
> "Chirag" <Chi...@discussions.microsoft.com> a écrit dans le message de
> .
>