Howto: 如何使用VBA检查文本或图形的拼写
文章编号 : 30905
软件: ArcGIS - ArcEditor 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcInfo 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcView 9.0, 9.1, 9.2, 9.3, 9.3.1
操作系统: N/A
软件: ArcGIS - ArcEditor 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcInfo 9.0, 9.1, 9.2, 9.3, 9.3.1 ArcGIS - ArcView 9.0, 9.1, 9.2, 9.3, 9.3.1
操作系统: N/A
1 个回复
EsriSupport
赞同来自:
内容: 按照下面的步骤:
1. 在ArcMap中创建一个新的UIButtonControl。
<a>详细步骤>></a>
A.选择工具 > 自定义,打开自定义对话框。
B. 选择命令条。
C. 从类别列表中选择UIControls。
D. 从save in下拉列表中选择Untitled来保存按钮,仅对该地图文档。选择Normal来保存按钮,对于机器上的所有ArcMap文档。
E. 点击新建 UIControl。
F. 选择UIButtonControl,单击创建。
G. 把新建的UIButtonControl拖到工具条中。
H. 关闭自定义对话框。
2. 打开Visual Basic Editor。
在ArcMap中选择工具 > Macros > Visual Basic Editor。
3. 打开工具 > References…
4. 确保选中’Microsoft Word X.X Object Library’。
5. 单击OK。
6. 在Project Explorer 窗口中,展开’Normal (Normal.mxt)’或’Project项目,选择ArcMap Objects > ThisDocument. 右击选中查看代码。
7. 在代码模块中粘贴如下代码。
Private Sub UIButtonControl1_Click()
Dim pDoc As IMxDocument
Set pDoc = ThisDocument
Dim pGC As IGraphicsContainerSelect
If pDoc.ActiveView Is pDoc.PageLayout Then
Set pGC = pDoc.PageLayout
Else
Set pGC = pDoc.FocusMap
End If
Dim pTE As ITextElement
Dim i As Integer
i = 0
Dim sz As String
Dim wdApp As Word.Application
Dim wdDoc As Document
'go through each selected element
Do Until i = pGC.ElementSelectionCount
'skip any non text elements
If Not TypeOf pGC.SelectedElement(i) Is ITextElement Then
i = i + 1
'check only text elements
Else
Set pTE = pGC.SelectedElement(i)
sz = pTE.Text
'add text to word document and open spell check
Set wdApp = New Word.Application
Set wdDoc = wdApp.Documents.Add
wdApp.Selection.Text = sz
wdApp.Dialogs(wdDialogToolsSpellingAndGrammar).Show
' if Cancel button is clicked, there will be one character
If Len(wdApp.Selection.Text) > 1 Then
'make spelling changes to the text element
pTE.Text = wdApp.Selection.Text
Else
wdApp.Quit
Set wdApp = Nothing
Exit Sub
End If
'Close Word
wdDoc.Close wdDoNotSaveChanges
wdApp.Quit
'next text element
i = i + 1
End If
Loop
Set wdApp = Nothing
pDoc.ActiveView.Refresh
End Sub
8. 单击new按钮,在地图文件中检查所有文本的拼写。
创建时间:2006-05-26
最近更新: 2012-02-28
【原文链接】
http://support.esrichina.com.c ... .html
要回复问题请先登录或注册