Quantcast
Channel: Excel IT Pro Discussions forum
Viewing all articles
Browse latest Browse all 11829

Excel Error "Office has detected a problem with this file. Editing it may harm your computer"

$
0
0

hi ,

i get the error in title while opening a file created with Excel2007 and saved as Excel 2003 but only when i put some chart in it with the code below.

If i comment the code the fle is opened normally.

What could cause the problem ? The file created has to be published on the intranet , i cannot disable the alert on all the client that could access it.

Thanks.

Function AddPercentageBarChart(DataSourceRange As Range, OverCells As Range) As ChartObject
    Dim chtObj As ChartObject

    Set chtObj = ActiveSheet.ChartObjects.Add(Left:=10, Width:=100, Top:=100, Height:=40)

    With chtObj.Chart
        .HasTitle = False
        .ChartType = xlBarClustered
        .SetSourceData Source:=DataSourceRange, PlotBy:=xlRows

        With .Axes(xlValue)
            .MinimumScale = 0
            .MaximumScale = 1
        End With
        .ChartArea.Format.Line.Visible = msoFalse              

        .SetElement msoElementPrimaryValueAxisNone 
        .SetElement msoElementPrimaryCategoryAxisNone
        .SetElement msoElementPrimaryValueGridLinesNone
        .SetElement msoElementLegendNone                        
        .PlotArea.Top = 0
        .PlotArea.Height = .Parent.Height
        .PlotArea.Border.LineStyle = xlNone
        .ChartGroups(1).GapWidth = 10                           

    End With
    
    Set AddPercentageBarChart = chtObj
End Function


                                        

Viewing all articles
Browse latest Browse all 11829

Trending Articles