This sample demonstrates how to use the CreateAPL method of the IArcPadExtension interface to write out ArcPad Layer files (*.apl) for all shapefile layers in the current map.
How to use
- Open ArcMap and add at least one shapefile.
- Paste the code into VBA and run the macro.
Public Sub CreateAPL()
'Get a reference to the ArcPad Extension
Dim pAPExtension As IArcPadExtension
Dim pID As New UID
pID = "editorExt.ArcPadExtension"
Set pAPExtension = Application.FindExtensionByCLSID(pID)
'Get a reference to the Map
Dim pMxDoc As IMxDocument
Dim pMap As IMap
Set pMxDoc = ThisDocument
Set pMap = pMxDoc.FocusMap
'Check each layer in the map to see if it is a shapefile
'If so, increment the shapefile counter and create an APL for it
Dim pLayer As ILayer
Dim pFLayer As IFeatureLayer
Dim pFClass As IFeatureClass
Dim pDataSet As IDataset
Dim lCount As Long, lShapefileCount As Long
For lCount = 0 To (pMap.LayerCount - 1)
Set pLayer = pMap.Layer(lCount)
If TypeOf pLayer Is IFeatureLayer Then
Set pFLayer = pLayer 'QI
Set pFClass = pFLayer.FeatureClass
Set pDataSet = pFClass 'QI
If pDataSet.Category = "Shapefile Feature Class" Then
lShapefileCount = lShapefileCount + 1
'Create an .APL file for the shapefile
pAPExtension.CreateAPL pLayer
End If
End If
Next
MsgBox lShapefileCount & " .APL file(s) created."
End Sub