Link to home
Start Free TrialLog in
Avatar of guidway
guidwayFlag for United States of America

asked on

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

guid
Avatar of guidway
guidway
Flag of United States of America image

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial