title: How do I debug this Excel Macro script and add exception handling?
body: <p>There are hundreds of excel files and I need to go through each of them and create some reports and graphs based on the content of them. However, it's extremely difficult to debug with the built-in excel vba debugger. Also, when the filename has a &quot;-&quot; in it, the macro stops working. How do I fix this? Below is the full code of the macro.</p>
  <pre><code>Sub ApplyLabelsAndClearZeros(ByVal chrt As Chart)
      Dim ser As Series
      For Each ser In chrt.SeriesCollection
          ser.ApplyDataLabels
          
          Dim pnt As Point
          For Each pnt In ser.Points
              If pnt.DataLabel.Text = &quot;0&quot; Then
                  pnt.HasDataLabel = False
              Else
                  pnt.DataLabel.ShowPercentage = True
                  pnt.DataLabel.ShowCategoryName = True
              End If
          Next
      Next
  End Sub
  </code></pre>