Perfect thank you! I am getting errors involving the if statement, if (map.getLayer(i).getName().equalsIgnoreCase(layerName)). I am getting errors:
'ESRI.ArcGIS.Carto.ILayer.Name.get': cannot explicitly call operator or accessor error
'ESRI.ArcGIS.Carto.IMap' does not contain a definition for 'getLayer" and no extension method 'getLayer' accepting a first argument of type 'ESRI.ArcGIS.Carto.IMap' could be found.
I can get map.get_Layer(i).Name.Equals(layerName); but I am still getting the error 'ESRI.ArcGIS.Carto.ILayer.Name.get': cannot explicitly call operator or accessor. I was wondering how to get around this?
Also, I was wondering what reference you use for AutomationException. I have been looking around on the internet but am failing to find it.