• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 421
  • Last Modified:

save .lyr (layer file) programmatically in ArcGIS 8

I've been up and down on Esri's website trying to find the solution to this, but can't get it to work. Basically I created a tool that when clicked creates a layer file for each map layer loaded. However they are only getting set to absolute paths, not relative so if I move it to another computer with the same structure but different drive letter it cannot find the layer. It works great through the ArcMap interface when I save a layer file manually but won't work programmatically. Something in the way the layer gets saved is the problem. Anyone have any idea how to fix this? thanks

1 Solution
guidwayAuthor Commented:
solved it, the solution is below, requesting closure of this question:

Public Sub StoreRelativeBase(inLayer As ILayer, inRelBase As String)
  Dim pDataLayer As IDataLayer2
  Set pDataLayer = inLayer
      pDataLayer.RelativeBase = inRelBase
  Dim pGxLayer As IGxLayer
  Dim pGxFile As IGxFile
  Set pGxLayer = New GxLayer
  Set pGxFile = pGxLayer
      pGxFile.Path = inRelBase & inLayer.Name & ".lyr"
      Set pGxLayer.Layer = inLayer
End Sub
Closed, 500 points refunded.
Community Support Moderator
Experts Exchange
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: CompTIA Cloud+

The CompTIA Cloud+ Basic training course will teach you about cloud concepts and models, data storage, networking, and network infrastructure.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now