Created this macro that allows you to copy a shape/object/image in Powerpoint and paste it to the position of your cursor rather than the default location of the place you copied from.
The method is slightly roundabout and you will need to add Rectangle to the Quick access toolbar but once you have, the Applescript code provided should accomplish the task.
The principle of the macro is as follows:
- Use the Insert Shape>Rectangle to activate Figure drawing drawing crosshairs on your current mouse locations (This has to be added to Quick Access Toolbar. Instructions below)
- Click mouse 1 to insert shape
- Note location of shape
- Delete shape
- Insert object from clipboard
- Relocate object to location of deleted shape.
Step 1 is to add the Insert Rectangle to the Quick Access Toolbar in PowerPoint. Go to menubar: Powerpoint>Preferences>Ribbon and Toolbar>Quick Access Toolbar. Choose commands from: All Commands. Scroll to Rectangle, and select the the Rectangle that is darker blue and looks like a square (on my computer, it's the middle one). Add it as the first quick access toolbar options. It has to be the first item on the Quick Access Toolbar for this to work. To confirm that you selected the right "Rectangle", when you click the icon (next to the minimize button of the window) it should activate crosshairs allowing you to draw the shape wherever you want.
Step 2: In BTT, create a new keyboard shortcut, and set the first action to Run Apple Script (blocking). The Applescript code should be:
tell application "System Events" to tell application process "Microsoft PowerPoint"
activate -- Attempt to bring PowerPoint to the foreground
delay 0.08 -- Wait; adjust this delay as necessary
tell window 1
click checkbox 1 of group 1 of toolbar 1
delay 0.02 -- Another delay to let the UI catch up
tell application "Microsoft PowerPoint" to activate -- Explicitly -- refocus PowerPoint
Step 3: The next action should be a Left Click (this inserts and selects the shape)
Step 4: The third and final action should be Run Apple Script (blocking). This is the code:
tell application "Microsoft PowerPoint"
run VB macro macro name "ReplacePlaceholderWithClipboard"
-- This assumes the macro is globally accessible or correctly scoped within PowerPoint
Now, the final step is to set up the macros using Powerpoint VBA. Go to Powerpoint>View (Ribbon)>Macros. Create a new one and name it "ReplacePlaceholderWithClipboard". Click 'Edit'. This will open the VBA editor window. Insert the following code:
Dim slideIndex As Integer
Dim leftPos As Single, topPos As Single
Dim shp As shape
slideIndex = ActiveWindow.View.slide.slideIndex
' Assuming a rectangle or any shape is selected, get its position
If ActiveWindow.Selection.Type = ppSelectionShapes Then
Set shp = ActiveWindow.Selection.ShapeRange(1)
leftPos = shp.Left
topPos = shp.Top
' Delete the placeholder rectangle
' Paste the shape from clipboard and move it to the noted location
On Error Resume Next ' In case there's nothing to paste
Set shp = ActivePresentation.Slides(slideIndex).Shapes.Paste(1)
On Error GoTo 0 ' Turn back on regular error handling
If Not shp Is Nothing Then
.Left = leftPos
.Top = topPos
MsgBox "Nothing was pasted. Ensure there's a shape in the clipboard.", vbExclamation
MsgBox "Please select a shape first.", vbCritical
Close the window.
You may need to grant privacy permissions to Powerpoint (and maybe BTT) to control the computer, but after that it should work. Now, when you copy some opject in powerpoint and press the keyboard shortcut, the object will be pasted at the location of your cursor. You may need to adjust the delays in the first Applescript code depending on your configuration.
First post here, let me know if the macro works!