Sub DragAndDrop
Sub DragAndDrop
DoEvents
' If the shape has text and we're starting to drag, copy it with its formatting to the clipboard
dx = GetSystemMetrics(SM_SCREENX)
dy = GetSystemMetrics(SM_SCREENY)
Drag oShp
' Paste the original text while maintaining its formatting, back to the shape
DoEvents
End Sub
#Else
#End If
' Change this value to change the timer to automatically drop the shape (can by integer or
decimal)
Const DropInSeconds = 5
' Get the system cursor coordinates
GetCursorPos mPoint
GetWindowRect mWnd, WR
sx = WR.lLeft
sy = WR.lTop
Debug.Print sx, sy
With ActivePresentation.PageSetup
Case dx > dy
dx = dy
Case dy > dx
dy = dx
End Select
End With
StartTime = Timer
While dragMode
GetCursorPos mPoint
' Comment out the next line if you do NOT want to show the countdown text within the shape
DoEvents
Wend
DoEvents
End Sub
Dim xl As Object ' Late binding (no reference to Excel library required)
Dim FormulaArray
' If the shape has text in it then evaluate the formula else do nothing...
If oShp.HasTextFrame Then
' Create an array of text strings by splitting the shape text concatenated with "=" using "=" as a
delimiter
' The additon of "=" guarantees that the array has at least 2 elements, in positions 0 and 1
' Replace all "," with "." in the first array entry (converting decimal format from EU to UK?)
Wend
' If there is some text in the first array cell then Evaluate it using Excel and save the result in the
2nd array element
' Note: Evaluate is not an Excel function but a formula auditing tool which shows you exactly
how the result is calculated
FormulaArray(1) = xl.Evaluate(FormulaArray)
' Concatenate the formula with the Evaluate text and save it back to the shape
End If
' Nudge the shape up and back down to the same position (forcing the slide to be refreshed
when DoEvents is called)
End If
DoEvents
End Sub