You are here: > ESRI Forums > arcgis desktop discussion forums > Thread Replies

ArcGIS Desktop Discussion Forums

ArcGIS Desktop - ArcObjects Visual Basic for Application (VBA) forum

Inserting Absolute Path into Textbox on Map...   john mcallister Jan 19, 2010
Re: Inserting Absolute Path into Textbox on...   Duncan Hornby Jan 20, 2010
Re: Inserting Absolute Path into Textbox on...   john mcallister Jan 20, 2010
Re: Inserting Absolute Path into Textbox on...   Duncan Hornby Jan 20, 2010
Re: Inserting Absolute Path into Textbox on...   john mcallister Jan 20, 2010
Re: Inserting Absolute Path into Textbox on...   Duncan Hornby Jan 20, 2010
Re: Inserting Absolute Path into Textbox on...   john mcallister Jan 20, 2010
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Inserting Absolute Path into Textbox on Map using VBA 
Author john mcallister 
Date Jan 19, 2010 
Message I think what I'm trying to do is fairly simple, but I'm not having any luck getting it to work. I have code that successfully gets the document path and filename and stores it into a variable, but I can't figure out how to get that value into an existing text box in the map called "txtFQPath". 
 
Public Sub AddMXDAbsolutePath()
    Dim DocAbsPath As String
    DocAbsPath = Application.Templates.Item(Application.Templates.Count - 1)
    'code below doesn't work.  Gives an "Object Required" message
    txtFQPath.Text = DocAbsPath
End Sub
 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Inserting Absolute Path into Textbox on Map using VBA 
Author Duncan Hornby 
Date Jan 20, 2010 
Message John,

Your code works fine for me. So is the form control you are writing the string to actually a textbox? If you are writing to a text LABEL then the property you need to write your string to is Caption

Duncan 
  GeoData Institute 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Inserting Absolute Path into Textbox on Map using VBA 
Author john mcallister 
Date Jan 20, 2010 
Message It's not a form control, it's just a text on the map in layout view. I tried the "Caption" property. Got the same error. Runtime error 424, Object Required.
I attached Screenshots of the Property box for the Text on the Map Layout, and a screenshot of the section of the map where the text is in map layout.
This is my first attempt at VBA in ESRI, so I'm probably doing it wrong but I can't find anything in the help menus or forums for using VBA to change a text box or whatever the formal name of this object is. 
 
Public Sub AbsolutePathName()
     Dim DocAbsPath As String
     DocAbsPath = Application.Templates.Item(Application.Templates.Count - 1)     
     txtFQPath.Caption = DocAbsPath
End Sub
 
  MapScreenshot.gif (opens in new window)
Text property Box.gif (opens in new window)
 
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Inserting Absolute Path into Textbox on Map using VBA 
Author Duncan Hornby 
Date Jan 20, 2010 
Message John,

Your use of the term textbox without giving context of where it is was misleading hence me assuming a form control. Anyway now we know what you are actually talking about I can help!

You need to get the graphics container for your pagelayout, cycle through through all the elements testing if they are a TEXTELEMENT and not what you refer to as a textbox. As you have given your textelement a name you can test for it's name using the interface IElementProperties3 then change the text to the mxd path using ITextElement.Text property

In the link below is some code which creates a textelement on a Map (not PageLayout) but you can see how one gets a handle on graphiccontainers and the interactions between Elements and TextElements

http://resources.esri.com/help/9.3/ArcGISDesktop/ArcObjects/esriCarto/ITextElement_Example.htm

Duncan 
  GeoData Institute 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Inserting Absolute Path into Textbox on Map using VBA 
Author john mcallister 
Date Jan 20, 2010 
Message I assumed I was using the wrong term, but I didn't know what the correct one was. Thanks for the help. Once I figure out how to modify this code I'm sure it will work. It's too bad there's nothing in the Help Menus on any of this. And if there is it's not easy to find. 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Inserting Absolute Path into Textbox on Map using VBA 
Author Duncan Hornby 
Date Jan 20, 2010 
Message John,

Welcome to the world of ArcObjects! Nothing is obvious but I find it's only the more obscure objects that are poorly documented. Generally you'll find some sort of help, especially here on the forum.

It will get even harder when ESRI drop VBA and you are forced to use VB .Net, now that's a language with with some really whacky sounding objects methods/properties!

Duncan 
  GeoData Institute 
   
Report Inappropriate Content • Top • Print • This Forum is closed for replies.    
Subject Re: Inserting Absolute Path into Textbox on Map using VBA 
Author john mcallister 
Date Jan 20, 2010 
Message Thanks again. That is a lot of objects for one text element. I can't believe I'm saying this, but this makes working with VBA in Microsoft software seem too simple. So far It seems like VBA is twice the work with ESRI. If VB.NET for ArcGIS is any more difficult I may take the easy way out and become a database administrator.