Screen capture and save using VBA Excel (Adding to existing Macro)

Loobc

New Member
Joined
Jul 10, 2020
Messages
2
Office Version
  1. 2010
Platform
  1. Windows
Afternoon Everyone,

Just looking for a little help; I have an existing macro that works perfectly for my needs, however I'm looking to add a screen capture functionality to it.

Ideally it would capture the window it is in and save it as a jpg, it would name the file using other data that in that Excel file e.g cell 1, cell 2 and cell 3.

Any ideas would be greatly received, VBA isn't my thing but I'm trying to learn it slowly!

Many Thanks,
L
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
welcome to MrExcel

This works for me
Amend to suit your requirements

VBA Code:
    Sub PasteScreenShot()
        Dim x, xChartArea, shp
        ActiveSheet.Activate
        ActiveWindow.VisibleRange.Cells(1, 1).Select
        Application.SendKeys "({1068})"       
        ActiveSheet.Paste
        Set shp = ActiveSheet.Shapes(Selection.Name)
        shp.CopyPicture
        Set x = ActiveSheet.ChartObjects.Add(0, 0, shp.Width, shp.Height)
        Set xChartArea = x.Chart
        x.Activate
        With xChartArea
            .ChartArea.Select
            .Paste
            .Export ("C:\Test\subfolderArea\" & "ScreenPicX" & ".jpg")
        End With
        x.Delete
        shp.Delete
    End Sub
 
Upvote 0

Forum statistics

Threads
1,214,992
Messages
6,122,631
Members
449,095
Latest member
bsb1122

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