Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to be able to develop a procedure that runs through all layers in the TOC and if the layer (name) exists in a specific folder where I am storing layer files with complex symbology I would like to import the procedure to import the symbology from the layer files. I have a similar procedure for importing stored Label schema so combining the two into a more dynamic solution would save me a lot of time. Thanks

share|improve this question
up vote 5 down vote accepted

A while back, I wrote some VB code to persist and de-persist renderers in ArcObjects. It's a slightly different spin on your question but I think what you need is there. The code can be found at:

I hope this helps.


share|improve this answer
Thanks Bill. I tried your script and just simply passed the path to the ".lyr" file as a parameter to the LoadRenderer procedure which raises an unspecified automation error. Any ideas? Thanks – Jakub Oct 8 '10 at 20:29
OK. It does work. When i create an ".agl" file with the SaveRenderer procedure i can successfully load it into a layer. Can i make this work with existing Layer Files? – Jakub Oct 8 '10 at 20:38
I suppose I should explain the intent of the code. A .lyr file saves the data source information and everything else necessary to recreate an object that implements ILayer. We didn't need that; we just wanted to save the renderer. As a result, it starts lower down in the object hierarchy. – Bill Dollins Oct 9 '10 at 11:00
Here's a link to a discussion of handling .lyr files in C#: – Bill Dollins Oct 9 '10 at 11:02
To open .lyr files, you should just be able to use the LayerFile coClass (…). With that, you can get at the layer through the ILayerFile.Layer property. You then need to cast it to an appropriate object (IGeoFeatureLayer for example) to get access to the Renderer property. – Bill Dollins Oct 9 '10 at 11:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.