How to Save Screenshot taken, to specific folder with specific name ?

ajay1111

New Member
Joined
Aug 15, 2022
Messages
17
Office Version
  1. 2016
Platform
  1. Windows
I found the code to take screenshot from the screen but could not figure out the way to save that screenshot to specific folder with specific name. What could be the way to achieve it ?
For Eg : Save the screenshot taken to "D:\Picture\Screenshot\First.jpg"

VBA Code:
Private Declare PtrSafe Sub keybd_event Lib "user32" (ByVal bVk As Byte, ByVal _
  bScan As Byte, ByVal dwFlags As Long, ByVal dwExtraInfo As Long)

Private Const VK_SNAPSHOT = &H2C

'Capture screen
Sub PrintScreen()
    keybd_event VK_SNAPSHOT, 1, 0, 0
    keybd_event VK_SNAPSHOT, 1, KEYEVENTF_KEYUP, 0  'Key Up
    'ActiveSheet.Paste
End Sub
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
Try:

VBA Code:
Sub Save_Screenshot()
  Dim sh As Worksheet
  Dim archivo As String
  '
  archivo = "C:\ejemplo\pantalla.jpeg"    'folder and file name
  Application.SendKeys "(%{1068})"
  DoEvents
  Set sh = Sheets.Add
  DoEvents
  sh.Shapes.AddChart
  With sh.ChartObjects(1)
      .Height = 500
      .Width = 1000
      .Chart.Paste
      .Chart.Export archivo
  End With
  Application.DisplayAlerts = False
  sh.Delete
  MsgBox "screenshot saved"
End Sub

Example:
 
Upvote 0
Solution

Forum statistics

Threads
1,214,573
Messages
6,120,318
Members
448,956
Latest member
Adamsxl

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top