Av8tordude
Well-known Member
- Joined
- Oct 13, 2007
- Messages
- 1,075
- Office Version
- 2019
- Platform
- Windows
This code allows me to copy/paste an image onto a blank chart object and then save the image to my computer. One thing really annoying is it must add a sheet for the blank chart object and then paste the blank chart object onto the main sheet and then delete the chart sheet. Can someone help me rewrite this code. Thanks
I tried this but I getting an error..
Set OHLCChart = Wks.ChartObjects.Add(0, 0, 600, 300)
I tried this but I getting an error..
Set OHLCChart = Wks.ChartObjects.Add(0, 0, 600, 300)
VBA Code:
Sub ExportMyPicture2()
Dim MyChart As String, MyPicture As String, FName As String
Dim PicWidth As Long, PicHeight As Long
Application.ScreenUpdating = False
MyPicture = ActiveCell.Value
Charts.Add
ActiveChart.Location Where:=xlLocationAsObject, Name:="Sheet1"
MyChart = Selection.Name & " " & Split(ActiveChart.Name, " ")(2)
With ActiveSheet
With .Shapes(MyChart)
.Width = 600
.Height = 300
End With
.Shapes(MyPicture).Copy
With ActiveChart
.ChartArea.Select
.Paste
End With
'FName = VBA.Environ("TEMP") & Application.PathSeparator & "MyPic.jpg"
'.ChartObjects(1).Chart.Export FName
.Shapes(MyChart).Delete
'.Shapes(MyPicture).Delete
'Kill FName
End With
End Sub