Alsatian
Alsatian

Reputation: 3135

Cannot save a workbook containing charts generated with VBA

Using Microsoft Excel 2013

In an empty new workbook, I can run successfull this macro :

Sub ReproduceError()

    Dim Sh As Worksheet
    Dim Ch As Chart

    Set Sh = ActiveWorkbook.Worksheets(1)
    Set Ch = Sh.Shapes.AddChart.Chart

End Sub

But when I'm trying to save the workbook, I receive this error :

Errors where detected while saving [file name]. Microsoft Excel may be able to save the file by removing or repairing some features. To make the repairs in a new file, click Continue. To cancel saving the file, click Cancel.

Upvotes: 1

Views: 914

Answers (1)

DDuffy
DDuffy

Reputation: 413

have you tried defining the range that the chart is to occupy?

Range("A10:B14").Select 
sh.Shapes.AddChart.Select

Upvotes: 1

Related Questions