save .lyr (layer file) programmatically in ArcGIS 8

Posted on 2004-04-14
Last Modified: 2010-08-05
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

Question by:guidway
LVL 12

Author Comment

ID: 10875137
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

Accepted Solution

modulo earned 0 total points
ID: 10875824
Closed, 500 points refunded.
Community Support Moderator
Experts Exchange

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ASP - create dynamic hyperlink 3 427
iPhone GPS Customer List 2 362
phone apps that transmit gps data 5 374
GPS save in database 19 58
I feel like more and more people want to know how to programmatically convert addresses into geospatial locations. So in this article, I will show you how you can do it with Bing Maps. I'm going to use PowerShell, which is a nice scripting language,…
Introduction This article is designed to assist GIS (Geographic Information System) and GPS (Global Positioning System) developers using ESRI ArcGIS and other spatial information management systems.   For the uninitiated the concept of projectio…
This tutorial demonstrates how to identify and create boundary or building outlines in Google Maps. In this example, I outline the boundaries of an enclosed skatepark within a community park.  Login to your Google Account, then  Google for "Google M…
This tutorial walks through the best practices in adding a local business to Google Maps including how to properly search for duplicates, marker placement, and inputing business details. Login to your Google Account, then search for "Google Mapmaker…

910 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now