-3
我正在使用此VBA代码将covnvert文本框文本转换为常规文本。但它通过shp.Type
和sString = Left(shp.TextFrame.TextRange.Text, _ shp.TextFrame.TextRange.Characters.Count - 1)
错误,而我在VB编译。如何修改VB的VBA代码
我应该在VB的代码中改变什么?
这是VBA代码:
Sub ConvertTextBoxToText()
Dim shp As Shape
Dim oRngAnchor As Range
Dim sString As String
For Each shp In ActiveDocument.Shapes
If shp.Type = msoTextBox Then
' copy text to string, without last paragraph mark
sString = Left(shp.TextFrame.TextRange.Text, _
shp.TextFrame.TextRange.Characters.Count - 1)
If Len(sString) > 0 Then
' set the range to insert the text
Set oRngAnchor = shp.Anchor.Paragraphs(1).Range
' insert the textbox text before the range object
oRngAnchor.InsertBefore sString
End If
shp.Delete
End If
Next shp
'Strip out beginning and ending textbox markers
Selection.HomeKey unit:=wdStory
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "Textbox start << "
.Replacement.Text = ""
.Forward = True
' .Wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = ">> Textbox end"
.Replacement.Text = ""
.Forward = True
.wrap = wdFindContinue
.Format = False
.MatchCase = True
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
VB代码:?
可以吗?
什么是错误在哪里? – Gareth
'shp.Type'和'sString = Left(shp.TextFrame.TextRange.Text,_ shp.TextFrame.TextRange.Characters.Count - 1)' – Pandu
什么是错误 – Gareth