?? vba14-2.txt
字號:
Private Function LoadShapefile(strPath As String, _
strFile As String, strName As String) As ILayer
' Load the shapefile based on the given path and name.
' Shapefile is added to the focus map as a layer.
' Layer is returned when successful.
Dim pWorkspaceFactory As IWorkspaceFactory
Dim pFeatureWorkspace As IFeatureWorkspace
Dim pFeatureClass As IFeatureClass
Dim pFeatureLayer As IFeatureLayer
Dim pMxDocument As IMxDocument
Dim pMap As IMap
Set pWorkspaceFactory = New ShapefileWorkspaceFactory
Set pFeatureWorkspace = pWorkspaceFactory. _
OpenFromFile(strPath, 0)
Set pFeatureClass = pFeatureWorkspace. _
OpenFeatureClass(strFile)
Set pFeatureLayer = New FeatureLayer
Set pFeatureLayer.FeatureClass = pFeatureClass
' Set the name and visibility of the layer.
pFeatureLayer.Name = strName
pFeatureLayer.Visible = True
' Add the shapefile to the focus map.
Set pMxDocument = Application.Document
Set pMap = pMxDocument.FocusMap
pMap.AddLayer pFeatureLayer
Set LoadShapefile = pFeatureLayer
End Function
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -