Want to take a screenshot and paste in excel file

Hi All,

I’m working on a workflow where I take a screenshot and store it in the clipboard using UiPath. The clipboard definitely has the image because when I manually press Ctrl + V, the screenshot pastes correctly.

However, when I try to automate this using the Keyboard Shortcuts activity (Ctrl + V), nothing gets pasted. Instead, it just types the letter v in the target application (Excel in my case).

Here’s what I’ve tried so far:

  • Verified that the clipboard contains the image.
  • Used Keyboard Shortcuts with Ctrl checked and key as v.
  • Tried enabling/disabling Simulate and SendWindowMessages.
  • Added delays and ensured the target element is active.

Still no luck. Has anyone faced this issue or knows how to reliably paste clipboard content (image) using UiPath?

Any suggestions or best practices would be greatly appreciated!

Hi @nitesh1890

This happens because Excel doesn’t accept simulated or window-message keystrokes for pasting images.

Activate the Excel window, then paste using Type Into with [k(ctrl)]v[k(ctrl)], keep SimulateType = False and SendWindowMessages = False. This reliably pastes the clipboard image.

2 Likes

1.Activate the Excel window(make sure the target cell is focused).
2. Use Type Into
3. Keep these settings:
SimulateType = False
SendWindowMessages = False
ClickBeforeTyping = True(recommended)
This sends a real keyboard paste event, allowing Excel to correctly paste the clipboard image.

Hi @nitesh1890

First save your screenshots in folder and try below approach

Regards,

1 Like

@nitesh1890

Keyboard shortcut will be unreliable here. Follow this

patternList.Any(Function(p) _
System.Text.RegularExpressions.Regex.IsMatch(
System.IO.Path.GetFileName(file),
“^” & p.Replace(“.”, “.”).Replace(“", ".”) & “$”
)
)

  • Verify whether editing is enabled in the Excel file.
  • Try pasting the image using the Insert option in Excel.
  • Open the image using the Snipping Tool and use the Copy option or the Ctrl + C shortcut.
  • Attempt to right-click and paste the image in Excel.

Doing UI Automation (ie clicking and typing) isn’t the correct way to work with Excel files. You should be using the Excel activities.

That being said, inserting images is painful. Sadly, UiPath doesn’t have any out-of-the-box activities for this. There are ways to do it using macros or VBA, and you can search the forum for those solutions.

listKey.Any(Function(k) System.Text.RegularExpressions.Regex.IsMatch(fileName, “^” & k & “" & userInput1 & "” & userInput2 & “.pdf$”, System.Text.RegularExpressions.RegexOptions.IgnoreCase))