It always helps if you choose Debug, Compile before trying to run a project.
It's also a good idea to add Option Explicit to the top of each module.
This forces you to be more careful about declaring variables.
First, Sub CmdClickDesktop_Click should appear after all the declarations.
Next, lFlags isn't dimmed in SendMouseLeftClick
But the biggie is the Screen.xxx stuff.
There's no Screen object in PPT vba, so this won't fly, I'm afraid.
In article <(E-Mail Removed)>, John Michl
wrote:
> Sub CmdClickDesktop_Click()
> Dim lX As Long
> Dim lY As Long
> lX = 1
> lY = 1
>
> MsgBox "About to send click"
> 'Send the mouse Left Button click
> SendMouseLeftClick lX, lY
> MsgBox "Sent Click"
> End Sub
>
> Private Type POINTAPI
> X As Long
> Y As Long
> End Type
>
> Declare Function SetCursorPos Lib "user32" _
> (ByVal X As Long, ByVal Y As Long) As Long
>
> Declare Sub mouse_event Lib "user32" _
> (ByVal dwFlags As Long, _
> ByVal dx As Long, _
> ByVal dy As Long, _
> ByVal cButtons As Long, _
> ByVal dwExtraInfo As Long)
>
> Private Const MOUSEEVENTF_MOVE = &H1
> Private Const MOUSEEVENTF_LEFTDOWN = &H2
> Private Const MOUSEEVENTF_LEFTUP = &H4
> Private Const MOUSEEVENTF_RIGHTDOWN = &H8
> Private Const MOUSEEVENTF_RIGHTUP = &H10
> Private Const MOUSEEVENTF_MIDDLEDOWN = &H20
> Private Const MOUSEEVENTF_MIDDLEUP = &H40
> Private Const MOUSEEVENTF_ABSOLUTE = &H8000
>
> Sub SendMouseLeftClick(ByVal lX As Long, ByVal lY As Long)
> 'NOTE: lX and lY are assumed to be Screen coordinates
> ' relative to the uper left corner (0,0).
> '''''''''''''''''''''''''''''''''''''''''''''''''''''
> 'Set cursor position
> SetCursorPos lX, lY
>
> 'Convert Pixel coordinates to Normalized ones
> ScreenToNormalizedCord lX, lY
>
> 'Send the mouse event
> lFlags = MOUSEEVENTF_LEFTDOWN Or MOUSEEVENTF_ABSOLUTE
> mouse_event lFlags, lX, lY, 0, 0
>
> lFlags = MOUSEEVENTF_LEFTUP Or MOUSEEVENTF_ABSOLUTE
> mouse_event lFlags, lX, lY, 0, 0
> End Sub
>
> Sub ScreenToNormalizedCord(lX As Long, lY As Long)
> 'Converts Screen coordinates in Pixels
> 'to Absolute normalized Screen coordinates.
> '''''''''''''''''''''''''''''''''''''''''''''
> Dim lScreenWidth As Long
> Dim lScreenHeight As Long
>
> 'Find Screen size in pixels
> lScreenWidth = Screen.Width \ Screen.TwipsPerPixelX
> lScreenHeight = Screen.Height \ Screen.TwipsPerPixelY
>
> 'Convert Pixel cordinates to absolute normalized ones
> lX = (lX / lScreenWidth) * 65535
> lY = (lY / lScreenHeight) * 65535
> End Sub
>
-----------------------------------------
Steve Rindsberg, PPT MVP
PPT FAQ:
www.pptfaq.com
PPTools:
www.pptools.com
================================================