Sudden error with

Wil Moosa

Well-known Member
Joined
Aug 11, 2002
Messages
893
While the code worked for a few days perfectly well it suddenly stopped at the line:

VBA Code:
Set oChrtO = oWs.ChartObjects.Add(Left:=0, Top:=0, Width:=lWidth, Height:=lHeight)

I also ran an early version of the workbook and there too the error occurs. Is this a memory thing or so? The full code is:

VBA Code:
[
Sub ExportDiagrammenFT()
 Dim rng As Range
 Dim oWs As Worksheet
 Dim oRng As Range
 Dim oChrtO As ChartObject
 Dim lWidth As Long, lHeight As Long
  On Error Resume Next
 
 Set oWs = ActiveSheet
 Set oRng = Worksheets("Grafieken_FT").Range("C1:O79")
    On Error GoTo 0
    If Not rng Is Nothing Then
        rng.Select
    End If
 oRng.CopyPicture xlScreen, xlPicture
 lWidth = oRng.Width
 lHeight = oRng.Height
 Set oChrtO = oWs.ChartObjects.Add(Left:=0, Top:=0, Width:=lWidth, Height:=lHeight)
 oChrtO.Activate
 With oChrtO.Chart
  .Paste
  .Export Filename:="C:\Test\Functiemix VH " & _
        Format(Date, "dd-mm-yyyy") & ".jpg", Filtername:="jpg"
 End With
 oChrtO.Delete
Range("A1").Select
MsgBox "Een schermafdruk met de actuele diagrammen functie- en niveaumix is opgeslagen in de map 'historie'."
End Sub

/CODE]
 

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
I got it, but it is quite embarassing. The sheet was protected but the code did not unprotect. Sorrie to bother you with this.
 
Upvote 0
Solution

Forum statistics

Threads
1,224,820
Messages
6,181,154
Members
453,021
Latest member
Justyna P

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