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?
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?