⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 sample vba code.mht

📁 ao的一些代码集合
💻 MHT
📖 第 1 页 / 共 5 页
字号:
s/定制ArcMap和ArcCatalog/sample_vba_code.htm#howSub4Anc=
hor"><IMG=20
height=3D11 alt=3D"expand/collapse item"=20
src=3D"file:///C:/Documents%20and%20Settings/YAZI/&#26700;&#38754;/Dechms=
/customizing_arcmap_and_arccatalog/small_arrow_up.gif"=20
width=3D11 border=3D0 name=3DimEx></A> =
&#22312;ArcMap&#20013;&#26816;&#26597;&#25991;&#26412;&#20803;&#32032;&#3=
0340;&#25340;&#20889;</H3></DIV>
<DIV class=3Dsubcontent id=3DhowSub4Content>
<H3>&#25551;&#36848;</H3>
<P class=3DBreak></P>
<P></P>&#20351;&#29992;&#26412;&#20363;&#20195;&#30721;&#23376;&#35843;&#=
29992;MicrosoftWord&#26469;&#26816;&#26597;ArcMap&#20013;&#25991;&#26412;=
&#30340;&#25340;&#20889;&#12290;&#39318;&#20808;&#65292;&#35201;&#36873;&=
#20013;&#20174;&#21738;&#24320;&#22987;&#26816;&#26597;&#25991;&#26412;&#=
65292;&#28982;&#21518;&#65292;&#21333;&#20987;&#26032;&#24314;&#30340;&#2=
5353;&#38062;&#26816;&#26597;&#25340;&#20889;&#12290;&#22914;&#26524;&#25=
340;&#20889;&#25110;&#35821;&#27861;&#26377;&#38169;&#35823;&#65292;&#235=
58;&#20250;&#24377;&#20986;&#23545;&#35805;&#26694;&#25552;&#37266;&#2032=
0;&#25913;&#27491;&#12290;=20

<P =
class=3DBreak></P>&#22312;&#26412;&#20363;&#20013;&#20320;&#23558;&#21521=
;&#24037;&#20855;&#26639;&#28155;&#21152;&#19968;&#20010;&#26032;&#30340;=
&#25353;&#38062;&#65292;&#24182;&#28155;&#21152;&#28304;&#20195;&#30721;&=
#12290;=20
<P class=3DBreak></P>
<H3>&#22914;&#20309;&#25805;&#20316;</H3>
<P class=3DBreak></P>
<P></P>
<OL>
  <LI>&#21551;&#21160;ArcMap.=20
  <P class=3DBreak></P>
  =
<LI>&#25171;&#24320;&#19968;&#20010;&#29616;&#23384;&#30340;&#22320;&#222=
70;&#25991;&#20214;&#65288;.mxd&#65289;&#65292;&#25110;&#23558;&#22270;&#=
23618;&#28155;&#21152;&#21040;&#31354;&#30333;&#30340;&#22320;&#22270;&#2=
5991;&#20214;&#12290;=20
  <LI>&#28155;&#21152;&#19968;&#20123;&#25991;&#23383;&#12290;=20
  <P class=3DBreak></P>
  <LI>=93Tools=94&#33756;&#21333;--&gt;=93Customize=94&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Commands=94&#26631;&#31614;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;=93Save=94&#32452;&#21512;&#26694;&#26049;&#30340;&#1=
9979;&#31661;&#22836;&#65292;&#24182;&#36873;&#25321;&#26032;&#21629;&#20=
196;&#23558;&#35201;&#20445;&#23384;&#30340;&#22320;&#22270;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28378;&#21160;=93&#31867;&#21035;=94&#21015;&#34920;&#26694;&#65292=
;&#28857;&#20987;=93UIControls=94&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93New UIControl=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;&#36873;&#25321;&#19968;&#20010;UIControl&#31867;&#22=
411;&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Create=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#23558;=93Commands=94&#21015;&#34920;&#26694;&#20013;&#26032;&#24314=
;&#30340;=93Project.UIButtonControl1=94&#25302;&#21160;&#21040;&#20219;&#=
24847;&#24037;&#20855;&#26639;&#19978;&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Create=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#21491;&#20987;&#21018;&#21046;&#20316;&#22909;&#30340;&#25353;&#380=
62;&#65292;&#28857;&#20987;=93View Source=94&#12290;=20
  <P =
class=3DBreak></P>&#36825;&#26679;&#20415;&#25171;&#24320;&#20102;Visual =
Basic Editor&#12290;=20
  <P class=3DBreak></P>
  <LI>&#22312;Visual Basic Editor&#20013;, =
"&#24037;&#20855;"--&gt;"&#24341;&#29992;"=20
  <P class=3DBreak></P>
  =
<LI>&#28378;&#21160;&#21487;&#29992;&#30340;&#24341;&#29992;&#24182;&#368=
73;&#25321;Microsoft Word 9.0 Object Library.=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;&#30830;&#23450;.=20
  <P class=3DBreak></P>
  =
<LI>&#22312;&#20195;&#30721;&#31383;&#21475;&#20013;&#65292;&#28857;&#209=
87;&#31243;&#24207;&#26694;&#26049;&#30340;&#19979;&#19977;&#35282;&#6528=
8;&#22312;&#31383;&#20307;&#30340;&#21491;&#36793;&#65289;&#65292;&#36873=
;&#25321;=93Click=94&#12290;=20
  <P =
class=3DBreak></P>&#36825;&#26679;&#20415;&#20026;&#20320;&#30340;&#36807=
;&#31243;&#25552;&#20379;&#20102;&#22836;&#23614;&#30340;&#20195;&#30721;=
&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#22797;&#21046;&#20197;&#19979;&#20195;&#30721;&#24182;&#31896;&#361=
48;&#22312;Click&#20107;&#20214;&#36807;&#31243;&#20013;&#12290;=20
  <P class=3DBreak></P>
  <P></P><PRE class=3Dcode><CODE>
Dim pDoc As IMxDocument
  Set pDoc =3D ThisDocument
  Dim pGC As IGraphicsContainerSelect
  If pDoc.ActiveView Is pDoc.PageLayout Then
    Set pGC =3D pDoc.PageLayout
  Else
    Set pGC =3D pDoc.FocusMap
  End If
  Dim pTE As ITextElement
   'Hard coded, check the first selected element
   Set pTE =3D pGC.SelectedElement(0)

  Dim sz As String
  sz =3D pTE.Text
  Dim wdApp As Word.Application
  Dim wdDoc As Document

  Set wdApp =3D New Word.Application
  Set wdDoc =3D wdApp.Documents.Add
  wdApp.Selection.Text =3D sz
  wdApp.Dialogs(wdDialogToolsSpellingAndGrammar).Show
   ' if Cancel button is clicked, there will be one character
   If Len(wdApp.Selection.Text) &gt; 1 Then
     pTE.Text =3D wdApp.Selection.Text
  Else
     wdApp.Quit
     Set wdApp =3D Nothing
     Exit Sub
  End If
  wdDoc.Close wdDoNotSaveChanges
  wdApp.Quit
  Set wdApp =3D Nothing
  pDoc.ActiveView.Refresh</CODE></PRE><BR>
  <P class=3DBreak></P>
  <P></P>
  <P></P>
  <LI>&#20851;&#38381;Visual Basic Editor.=20
  <P class=3DBreak></P>
  <P></P>
  <LI>&#22312;ArcMap&#31383;&#21475;&#20013;, =
&#29992;&#36873;&#25321;&#24037;&#20855;&#36873;&#25321;&#19968;&#27573;&=
#25991;&#26412;&#12290;=20
  <P></P>
  =
<LI>&#28857;&#20987;&#26032;&#30340;&#25353;&#38062;&#36816;&#34892;&#253=
40;&#20889;&#26816;&#26597;&#23439;&#21629;&#20196;&#12290; </LI></OL>
<P class=3DBreak></P>
<P></P>
<TABLE cellPadding=3D5 width=3D"85%" border=3D0>
  <TBODY>
  <TR>
    <TD>
      <H3>&#25552;&#31034;</H3>
      <UL>
        =
<LI>&#35831;&#30830;&#23450;VB&#20013;&#30340;&#20195;&#30721;&#26159;&#2=
0197;&#20197;&#19978;&#27493;&#39588;&#20013;&#30340;&#26684;&#24335;&#20=
986;&#29616;&#12290;&#20363;&#22914;&#65292;&#20320;&#21487;&#33021;&#386=
56;&#35201;&#33258;&#24049;&#21152;&#20123;&#22238;&#36710;&#12290; =
</LI></UL>
      <P></P>
      <P class=3DBreak></P>
      <P></P></TD></TR></TBODY></TABLE></DIV>
<DIV class=3Dsubhead id=3DhowSub5><A name=3DhowSub5Anchor></A>
<H3><A onclick=3D"expandIt('howSub5')"=20
href=3D"file:///C:/Documents%20and%20Settings/YAZI/&#26700;&#38754;/Dechm=
s/&#23450;&#21046;ArcMap&#21644;ArcCatalog/sample_vba_code.htm#howSub5Anc=
hor"><IMG=20
height=3D11 alt=3D"expand/collapse item"=20
src=3D"file:///C:/Documents%20and%20Settings/YAZI/&#26700;&#38754;/Dechms=
/customizing_arcmap_and_arccatalog/small_arrow_up.gif"=20
width=3D11 border=3D0 name=3DimEx></A> =
&#35745;&#31639;&#21306;&#22495;&#20869;&#35201;&#32032;&#30340;&#25968;&=
#37327;</H3></DIV>
<DIV class=3Dsubcontent id=3DhowSub5Content>
<H3>&#25551;&#36848;</H3>
<P class=3DBreak></P>
<P></P>&#26412;&#33539;&#20363;&#20351;&#29992;&#19968;&#20010;&#31354;&#=
38388;&#26597;&#35810;&#36807;&#28388;&#22120;&#26469;&#35745;&#31639;&#2=
1306;&#22495;&#20869;&#35201;&#32032;&#30340;&#25968;&#37327;<SPAN=20
xmlns:user=3D"http://www.esri.com/ContentStudio"=20
xmlns:msxsl=3D"urn:schemas-microsoft-com:xslt">&#12290;&#39318;&#20808;&#=
65292;&#28857;&#20987;&#24037;&#20855;&#26639;&#19978;&#33258;&#21019;&#2=
4314;&#30340;&#25353;&#38062;&#65292;&#28982;&#21518;&#22312;&#35201;&#35=
745;&#25968;&#30340;&#35201;&#32032;&#21608;&#22260;&#25302;&#20986;&#199=
68;&#20010;&#30697;&#24418;&#26694;&#12290;&#31243;&#24207;</SPAN>=20
The program retrieves the cursor's locations based on a filter, then =
loops=20
through a counting procedure of all the features. The number of points, =
lines,=20
and areas are totaled and reported to the user in a message box.=20
<P class=3DBreak></P>
<P></P>In this sample, you will be adding a control button and writing =
the code=20
for it.
<P class=3DBreak></P>
<P></P>
<H3>&#22914;&#20309;&#25805;&#20316;</H3>
<P class=3DBreak></P>
<P></P>
<OL>
  <LI>&#21551;&#21160;ArcMap.=20
  <P class=3DBreak></P>
  <P class=3DBreak></P>
  =
<LI>&#25171;&#24320;&#19968;&#20010;&#29616;&#23384;&#30340;&#22320;&#222=
70;&#25991;&#20214;&#65288;.mxd&#65289;&#65292;&#25110;&#23558;&#22270;&#=
23618;&#28155;&#21152;&#21040;&#31354;&#30333;&#30340;&#22320;&#22270;&#2=
5991;&#20214;&#12290;=20
  <P class=3DBreak></P>
  <LI>=93Tools=94&#33756;&#21333;--&gt;=93Customize=94&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Commands=94&#26631;&#31614;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;=93Save=94&#32452;&#21512;&#26694;&#26049;&#30340;&#1=
9979;&#31661;&#22836;&#65292;&#24182;&#36873;&#25321;&#26032;&#21629;&#20=
196;&#23558;&#35201;&#20445;&#23384;&#30340;&#22320;&#22270;&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28378;&#21160;=93&#31867;&#21035;=94&#21015;&#34920;&#26694;&#65292=
;&#28857;&#20987;=93UIControls=94&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93New UIControl=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;&#36873;&#25321;&#19968;&#20010;UIControl&#31867;&#22=
411;&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Create=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#23558;=93Commands=94&#21015;&#34920;&#26694;&#20013;&#26032;&#24314=
;&#30340;=93Project.UIToolControl1=94&#25302;&#21160;&#21040;&#20219;&#24=
847;&#24037;&#20855;&#26639;&#19978;&#12290;=20
  <P class=3DBreak></P>
  <LI>&#28857;&#20987;=93Create=94&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#21491;&#20987;&#21018;&#21046;&#20316;&#22909;&#30340;&#25353;&#380=
62;&#65292;&#28857;&#20987;=93View Source=94&#12290;=20
  <P =
class=3DBreak></P>&#36825;&#26679;&#20415;&#25171;&#24320;&#20102;Visual =
Basic Editor&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#22312;&#20195;&#30721;&#31383;&#21475;&#20013;&#65292;&#28857;&#209=
87;&#31243;&#24207;&#26694;&#26049;&#30340;&#19979;&#19977;&#35282;&#6528=
8;&#22312;&#31383;&#20307;&#30340;&#21491;&#36793;&#65289;&#65292;&#36873=
;&#25321;=93Click=94&#12290;=20
  <P =
class=3DBreak></P>&#36825;&#26679;&#20415;&#20026;&#20320;&#30340;&#36807=
;&#31243;&#25552;&#20379;&#20102;&#22836;&#23614;&#30340;&#20195;&#30721;=
&#12290;=20
  <P class=3DBreak></P>
  =
<LI>&#22797;&#21046;&#20197;&#19979;&#20195;&#30721;&#24182;&#31896;&#361=
48;&#22312;Click&#20107;&#20214;&#36807;&#31243;&#20013;&#12290;=20
  <P class=3DBreak></P>
  <P></P>
  <P></P><PRE class=3Dcode><CODE>Dim pMxDoc As IMxDocument
Set pMxDoc =3D ThisDocument

Dim pEnv As IEnvelope
Dim pRubber As IRubberBand
Set pRubber =3D New RubberEnvelope

Dim pActiveView As IActiveView
Set pActiveView =3D pMxDoc.FocusMap
Set pEnv =3D pRubber.TrackNew(pActiveView.ScreenDisplay, Nothing)

Dim pSpatialFilter As ISpatialFilter
Set pSpatialFilter =3D New SpatialFilter
Set pSpatialFilter.Geometry =3D pEnv
pSpatialFilter.SpatialRel =3D esriSpatialRelIntersects

Dim lPoints As Long, lPolylines As Long, lPolygons As Long
Dim pLayer As IFeatureLayer
Dim pFeatureCursor As IFeatureCursor
Dim pFeature As IFeature
Dim i As Long
For i =3D 0 To pMxDoc.FocusMap.LayerCount - 1
  If (TypeOf pMxDoc.FocusMap.Layer(i) Is IGeoFeatureLayer) Then
     Set pLayer =3D pMxDoc.FocusMap.Layer(i)
     pSpatialFilter.GeometryField =3D pLayer.FeatureClass.ShapeFieldName

     Set pFeatureCursor =3D pLayer.Search(pSpatialFilter, True)
     Set pFeature =3D pFeatureCursor.NextFeature
     Do Until (pFeature Is Nothing)
       Select Case pFeature.Shape.GeometryType
         Case esriGeometryPoint
           lPoints =3D lPoints + 1
         Case esriGeometryPolyline
           lPolylines =3D lPolylines + 1
         Case esriGeometryPolygon
           lPolygons =3D lPolygons + 1
        End Select
        Set pFeature =3D pFeatureCursor.NextFeature
     Loop
  End If
Next i

MsgBox "Features Found:" &amp; vbCrLf &amp; lPoints &amp; " Points " =
&amp; vbCrLf &amp; _
lPolylines &amp; " Polylines " &amp; vbCrLf &amp; lPolygons &amp; " =
Polygons "</CODE></PRE><BR>
  <P class=3DBreak></P>
  <P></P>
  <P></P>
  <P></P>
  <LI>&#20851;&#38381;Visual Basic Editor.=20
  <P class=3DBreak></P>
  =
<LI>&#28857;&#20987;&#22312;ArcMap&#20013;&#26032;&#24314;&#30340;Toolbut=
ton,&#28982;&#21518;&#25302;&#21160;&#40736;&#26631;&#36873;&#20013;&#352=
01;&#35745;&#25968;&#30340;&#21306;&#22495;&#12290; </LI></OL>
<P class=3DBreak></P>
<P></P>
<P></P>
<TABLE cellPadding=3D5 width=3D"85%" border=3D0>
  <TBODY>
  <TR>
    <TD>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -