VBA export range as JPEG

Blueorangez

New Member
Joined
Dec 15, 2016
Messages
14
Sub ExportRange()

Const FName As String = "C:\TEMP\export.jpg"
Dim rng As Range
Dim shtTemp As Worksheet
Dim chtTemp As Chart

Application.ScreenUpdating = False
'// Change range as needed
Set rng = Worksheets("Daily Roster").Range("A128:K153")

'// Add a temp worksheet. Chart will be placed on this. It will be deleted after
Set shtTemp = Worksheets.Add
'// Add chart
Charts.Add
'// Move the chart to the new sheet and get a reference to it
ActiveChart.Location Where:=xlLocationAsObject, Name:=shtTemp.Name
Set chtTemp = ActiveChart

'// Copy and paste the range
rng.CopyPicture Appearance:=xlScreen, Format:=xlPicture
chtTemp.Paste

'// Export
chtTemp.Export FileName:="C:\Users\user1\Desktop\123.jpeg"

'// Tidy up...
Application.DisplayAlerts = False
shtTemp.Delete
Application.DisplayAlerts = True
Application.ScreenUpdating = True

End Sub





I have this code above which is working but the picture it exports is to small and not readable.

is there some code that can be added to increase the size of the chart before it is exported?
 

Excel Facts

Quick Sum
Select a range of cells. The total appears in bottom right of Excel screen. Right-click total to add Max, Min, Count, Average.
any help?

Code:
Sub saveChart()
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    With Charts.Add
        .Export "C:\Users\user1\Desktop\123.jpeg"
        .Delete
    End With
    Application.ScreenUpdating = True
    Application.DisplayAlerts = True
End Sub
 
Upvote 0

Forum statistics

Threads
1,215,053
Messages
6,122,882
Members
449,097
Latest member
dbomb1414

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