IRbbionx<;编辑框/>;如何传递对VBA代码的引用
上面是我的xml和vba代码, 当我在editbox中写“1”时,我想找到图1IRbbionx<;编辑框/>;如何传递对VBA代码的引用,vba,ms-word,Vba,Ms Word,上面是我的xml和vba代码, 当我在editbox中写“1”时,我想找到图1 当我在编辑框中写“1”时,msgbox可以显示“图1”,但我的单词不能显示“图1”。因为“Figure”&Str(strText)不是字符串?下面的代码将在标题中找到数字。您可能需要调整它以找到该数字所在的图片 Sub jump_to_caption_item(ByVal control As IRibbonControl, ByRef strText) selection.collapse Direc
当我在编辑框中写“1”时,msgbox可以显示“图1”,但我的单词不能显示“图1”。因为“Figure”&Str(strText)不是字符串?下面的代码将在标题中找到数字。您可能需要调整它以找到该数字所在的图片
Sub jump_to_caption_item(ByVal control As IRibbonControl, ByRef strText)
selection.collapse Direction:=wdCollapseEnd
a = "Figure " & Str(strText)
MsgBox a
With selection.Find
.Font.Bold = True
.Text = "Figure " & Str(strText)
.Forward = True
.Wrap = wdFindContinue
.MatchWildcards = False
.Replacement.Text = ""
.Execute
End With End Sub
Sub的参数Num
是要查找的标题编号。用这样的代码调用sub
Private Sub GoToFigure(ByVal Num As Integer)
' 27 Dec 2017
Dim Fld As Field
For Each Fld In ActiveDocument.Fields
With Fld
If (.Type = wdFieldSequence) And _
(InStr(1, .Code, "figure", vbTextCompare) > 0) Then
If .Result = Num Then
.Select
End If
End If
End With
Next Fld
End Sub
其中“1”是编辑框中的数字。在我看来,否决票的申请过于仓促。这个问题比它的表达方式更有价值。对不起,我的英语不好,可能表达不清楚,谁能知道我的代码哪里有问题,提供点帮助我非常感谢,我将
Str(strText)
改为CInt(strText)
是访问doI的权限我很高兴能帮助你,克里。请将我的答案标记为“已选择”。非常感谢。
Private Sub GoToFigure(ByVal Num As Integer)
' 27 Dec 2017
Dim Fld As Field
For Each Fld In ActiveDocument.Fields
With Fld
If (.Type = wdFieldSequence) And _
(InStr(1, .Code, "figure", vbTextCompare) > 0) Then
If .Result = Num Then
.Select
End If
End If
End With
Next Fld
End Sub
GoToFigure 1