I have a DLL file that I have loaded and registered it in ArcGIS as a command icon. This icon launches a window where the user should do the following selections: an input file, a field name, select between 2 option buttons and an output file name. However, I need to run this DLL file via a VBA and ArcObjects code so as the user will not see the window of the DLL tool and the above selections will be given automatically by the code within a loop so as to take various output files. Is that possible? Please help.
Thanks
Demetris
Eventually I found a function that may be is approprite to call the DLL file. I declare it below and I try to call it via the Calldll() procedure. However, I receive the following message "Run-time error 13- Type mismatch". I think that the arguments have the appropriate data type. Could you please have a look in the code below to find what is going on?
Thanks again
Demetris
Public Declare Function CreateParcelsShape Lib "C:\Program Files\ArcGIS\CreatePoly.dll" (Centroids As IFeatureClass, Block As IPolygon, pFDS As IFeatureDataset)
Public Sub CallDll()
Dim pMxDoc As IMxDocument
Set pMxDoc = ThisDocument
'Get the active map (data frame)
Dim pMap As IMap
Set pMap = pMxDoc.FocusMap
'Get the layers
Dim pLayers As IEnumLayer
Set pLayers = pMap.Layers
Dim pLayer1 As ILayer
Set pLayer1 = pLayers.Next
Do Until pLayer1 Is Nothing
If pLayer1.Name = "Block12" Then
Exit Do
End If
Set pLayer1 = pLayers.Next
Loop
Dim pBlocks As IFeatureLayer
Set pBlocks = pLayer1
Dim pBlocksFC As IFeatureClass
Set pBlocksFC = pBlocks.FeatureClass
Dim pBlocksCursor As IFeatureCursor
Set pBlocksCursor = pBlocksFC.Search(Nothing, False)
Dim pBlockFeature As IFeature
Set pBlockFeature = pBlocksCursor.NextFeature
'Get the shape of the polygon (Block)
Dim polygon As IPolygon
Set polygon = pBlockFeature.Shape
Dim pLayers2 As IEnumLayer
Set pLayers2 = pMap.Layers
Dim pLayer2 As ILayer
Set pLayer2 = pLayers2.Next
Do Until pLayer2 Is Nothing
If pLayer2.Name = "CentroidsBlock12" Then
Exit Do
End If
Set pLayer2 = pLayers2.Next
Loop
Dim pCentroids As IFeatureLayer
Set pCentroids = pLayer2
Get the dataset
Dim pFDataSet As IFeatureDataset
Dim pFWorkspace As IFeatureWorkspace
Dim pAWFactory As IWorkspaceFactory
Set pAWFactory = New AccessWorkspaceFactory
Set pFWorkspace = pAWFactory.OpenFromFile("C:\LACONISS\GAPopulation.mdb", 0)
Set pFDataSet = pFWorkspace.OpenFeatureDataset("Polygons")
'Call the DLL function
CreateParcelsShape pCentroids, polygon, pFDataSet
End Sub
Best Answer
It looks like
CreateThiessenPoly.dll
has aDllRegisterServer
hook, so it is a DLL COM file, which means you can directly reference it from VBA. Note: I used Dependency Walker to determine that you may needmsvbvm60.dll
fromvbrun60.cab
(the module was programmed/compiled from Visual Basic 6.)From the VBA development environment (
I'm actually using Excel's, tested again on a Win32 computer with ArcInfo 9.3), you should go to: Tools > References..., and browse toCreateThiessenPoly.dll
. This will add a reference to "TgisThPoly".Unfortunately, I don't see anything too interesting in the module:
Furthermore, you can create an instance of the class, but it doesn't have any publicly accessible members, so there is nothing we can do with it. The following code runs from VBA in ArcInfo 9.3 without any errors:
Maybe you might see something different from another VBA environment (e.g., if registered/used from Visual Basic 6.0, or from ArcGIS 8.1). The DLL probably has many more private functions, which we cannot get to in any way.
Your best option is to find a different approach altogether, which would be best addressed in a separate question, e.g., as matt suggests: "How can I create Thiessen Polygons without an Arcinfo license?"