GTVx is an ActiveX control version of GTViewer. You can drop GTViewer’s functionality into anything that supports ActiveX control. Most of the applications written with GTVx are based around Visual Basic 6.0 or Visual Basic .NET; however, GTVx is a standard ActiveX control and there are many applications that can make use of it that are not traditional development platforms. In this posting, I will show how you can use GTVx with Excel to enhance a simple report with Map Display capabilities.
Let’s start with a simple report in Excel showing a list of Poles and various information including an X and a Y coordinate. Incidentally, this report was made with GTViewer’s Feature Counting command and pasted in Excel.
Activate the Visual Basic Editor in Excel by selecting Tools/Macros/Visual Basic Editor. Then add a new user form by selecting Insert/UserForm and call it UserForm1.
On your blank form, you need to place the GTVx control. By default, GTVx does not appear on the toolbox containing all of the controls you can place. Right mouse click on the toolbox and select Additional Controls and select GTVx. Place the GTVx control on the form. Then add the following code to the form to show the pole on the selected row in the Spreadsheet:
Private Sub UserForm_Initialize()
If GTVX1.OpenFile("c:\temp\demo.gtx") Then
r = Application.ActiveCell.Row
x = Application.ActiveSheet.Cells(r, 7) ' x position
y = Application.ActiveSheet.Cells(r, 8) ' y position
GTVX1.SetViewCenter 1, x, y, 350
This form is simply getting the X and Y values out of the selected row and then centering on the pole at a predetermined zoom level of 350. This code assumes you have a file called demo.gtx in your temp directory, but you could have used GTVx’s DownloadFile method to retrieve a file from the internet if not present, or accessed the file by a UNC name somewhere else on your network. GTVx currently has over 370 methods and captures over 40 events providing a very powerful development environment. However, with all of these methods available to you, it can be very simple to complete a specific task with only 2 methods as seen in this example.
To activate the Map from the spreadsheet, I placed a button at the top of the Report in the Spreadsheet and associated it with the following macro:
This macro just loads and shows the created above.
This may be a trivial use of GTVx, but I hope that it shows the power that GTVx can provide to your applications with minimal effort. GTVx can be placed in an existing application to provide map displays and access to your feature tabular information or an entirely new application can be built around it. For more information on developing with GTViewer and GTVx, see is previous Blog posting.
Post a Comment