Run Time Error '1004' Copypicture method of range class failed

mk4646

New Member
Joined
Nov 11, 2021
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello, so i've been running this macro now for several years daily to output football statistics, randomly today its throwing this error at me and i have no idea how to solve it!

please help!! thank you in advance


rgExp.CopyPicture Appearance:=xlScreen, Format:=xlBitmap <----------- debug highlights this line



VBA Code:
Sub CharlieExport()

Dim filename1 As String
Dim Path As String
Dim Myrange As String
Dim dvCell As Range
Dim inputRange As Range
Dim c As Range
Dim i As Long

Set dvCell = Worksheets("Fixtures").Range("L1")
Set inputRange = Evaluate(dvCell.Validation.Formula1)
i = 1


Application.ScreenUpdating = True
For Each c In inputRange
dvCell = c.Value


Myrange = Worksheets("Macro Info").Range("B4").Value
    Dim rgExp As Range: Set rgExp = Worksheets("ministat").Range(Myrange)
    ''' Copy range as picture onto Clipboard
    rgExp.CopyPicture Appearance:=xlScreen, Format:=xlBitmap
    Application.ScreenUpdating = True
    ''' Create an empty chart with exact size of range copied
    With ActiveSheet.ChartObjects.Add(Left:=rgExp.Left, Top:=rgExp.Top, _
    Width:=rgExp.Width, Height:=rgExp.Height)
    .Name = "TempChart"
    .Activate
    End With
    ''' Paste into chart area, export to file, delete chart.
    Application.ScreenUpdating = True
    ActiveChart.Paste
    Application.Wait (Now + TimeValue("0:00:01"))
   Path = Worksheets("Macro Info").Range("K6").Value
    filename1 = Worksheets("ministat").Range("A11") & "Mini-10" & ".jpeg"
    ActiveSheet.ChartObjects("TempChart").Chart.Export (Path & filename1)
    ActiveSheet.ChartObjects("TempChart").Delete

Next c
Application.ScreenUpdating = True
MsgBox ("Saved")

End Sub
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
You could trial changing this...
Code:
Dim Myrange As Range
and just using this....
Code:
rgExp.CopyPicture
HTH. Dave
ps. Welcome to the Board!
 
Upvote 0

Forum statistics

Threads
1,214,817
Messages
6,121,720
Members
449,050
Latest member
MiguekHeka

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