We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 4c75b9c commit 13de962Copy full SHA for 13de962
VBA Script/文本框转文字.vba
@@ -0,0 +1,29 @@
1
+Sub ConvertTextBoxesToText()
2
+ Dim shp As Shape
3
+ Dim rng As Range
4
+ Dim textToInsert As String
5
+
6
+ '确保有内容被选中
7
+ If Selection.Type <> wdSelectionShape Then
8
+ MsgBox "请先选择文本框。"
9
+ Exit Sub
10
+ End If
11
12
+ '遍历选中的文本框
13
+ For Each shp In Selection.ShapeRange
14
+ If shp.Type = msoTextBox Then
15
+ '提取文本框中的文本
16
+ textToInsert = shp.TextFrame.TextRange.Text
17
+ '删除文本框
18
+ shp.Delete
19
+ '将文本插入到文档中
20
+ If rng Is Nothing Then
21
+ Set rng = ActiveDocument.Range(Selection.Start, Selection.Start)
22
+ Else
23
+ Set rng = ActiveDocument.Range(rng.End, rng.End)
24
25
+ rng.InsertAfter textToInsert
26
+ rng.Collapse wdCollapseEnd
27
28
+ Next shp
29
+End Sub
0 commit comments