vbscript 单词add_link

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了vbscript 单词add_link相关的知识,希望对你有一定的参考价值。

'从data的table读取将添加link的第n个。data的表格,都从0开始。
'add_link_21,是在每个被跳转的字段,添加bmark和jump
'add_link_22,是在表格中,一步步添加jump
Sub add_link_21()
    Dim mTab As Word.Table
    Set mTab = ActiveDocument.Tables(1)
    num1 = Replace(mTab.Cell(1, 2).Range.Text, Chr$(13) & Chr$(7), "")
    'mTab.Cell(1, 2).Range.Text = Int(num1) + 1 '挪到最后
    num1 = Right(0 & Int(num1) + 1, 2)
    '----------
    Selection.TypeText Text:="--------------------"
    For i = 1 To 4
        Selection.TypeParagraph
    Next
    '---
    Selection.TypeText Text:="@jump_" & num1
    Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
    a1 = Replace(Selection.Range.Text, "@", "")
    With ActiveDocument.Bookmarks
        .Add Range:=Selection.Range, Name:=a1
        .DefaultSorting = wdSortByName
        .ShowHidden = False
    End With
    Selection.EndKey Unit:=wdLine
    For i = 1 To 2
        Selection.TypeParagraph
    Next
    '---
    ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="", _
        SubAddress:="jump_00", ScreenTip:="", TextToDisplay:="$jump_00"
    Selection.EndKey Unit:=wdLine
    For i = 1 To 2
        Selection.TypeParagraph
    Next
    '---
    mTab.Cell(1, 2).Range.Text = Int(num1) '+ 1
End Sub
Sub add_link_22()
    Dim mTab As Word.Table
    Set mTab = ActiveDocument.Tables(1)
    num1 = Replace(mTab.Cell(2, 2).Range.Text, Chr$(13) & Chr$(7), "")
    mTab.Cell(2, 2).Range.Text = Int(num1) + 1
    num1 = Right(0 & Int(num1) + 1, 2)
    '---
    ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="", _
        SubAddress:="jump_" & num1, ScreenTip:="", TextToDisplay:="$jump_" & num1
    Selection.EndKey Unit:=wdLine
    '-----
    Selection.MoveDown Unit:=wdLine, Count:=1
End Sub


Sub add_link_and_title1()
    '需先添加add1的书签
    i1 = Selection.Range.Cells(1).RowIndex
    j1 = Selection.Range.Cells(1).ColumnIndex '4
    n1 = get_form_number '2
    '---
    num1 = Mid(Year(Date), 3, 2) & Format(Month(Date), "00") _
& Format(Day(Date), "00") & "_" & Format(Hour(Time), "00") _
& Format(Minute(Time), "00") & Format(Second(Time), "00")
    '---
    ActiveDocument.Hyperlinks.Add Anchor:=Selection.Range, Address:="", _
        SubAddress:="a" & num1, ScreenTip:="", TextToDisplay:="a" & num1
    Selection.EndKey unit:=wdLine
    '-----
    Selection.GoTo what:=wdGoToBookmark, Name:="add1"
    Selection.MoveUp unit:=wdLine, count:=2
'    Selection.MoveRight unit:=wdCharacter, Count:=1
    '-----
    Selection.TypeText Text:="a" & num1
    Selection.HomeKey unit:=wdLine, Extend:=wdExtend
    a1 = Selection.Range.Text
    With ActiveDocument.Bookmarks
        .Add Range:=Selection.Range, Name:=a1
        .DefaultSorting = wdSortByName
        .ShowHidden = False
    End With
    Selection.MoveLeft unit:=wdCharacter, count:=1
    Selection.TypeText Text:="t_//\"
    Selection.EndKey unit:=wdLine
    Selection.TypeText Text:="\"
    '---
    For i = 1 To 3
        Selection.TypeParagraph
    Next
    '-----
    gototable1 n1, i1, j1
End Sub
Function gototable1(i, i1, j1, Optional next1 = 1)
'    Dim mTab As Word.Table
    Set mTab = ActiveDocument.Tables(i)
    mTab.Cell(i1, j1).Range.Select
    Selection.MoveLeft unit:=wdCharacter
    If next1 = 1 Then Selection.MoveDown unit:=wdLine, count:=1
End Function

Sub get_title_ang_tag1()
    i1 = Selection.Range.Cells(1).RowIndex
    j1 = 2 'Selection.Range.Cells(1).ColumnIndex
    n1 = get_form_number
    j_bm = 4
    Dim mTab As Word.Table
    Set mTab = ActiveDocument.Tables(n1)
    bk1 = Replace(mTab.Cell(i1, j_bm).Range.Text, Chr$(13) & Chr$(7), "")
    Selection.GoTo what:=wdGoToBookmark, Name:=bk1
    Selection.HomeKey unit:=wdLine
    a0 = Split(Selection.Paragraphs(1).Range.Text, Chr(13))(0)
    a1 = reg1("\/(.*?)\/", a0)
    a2 = reg1("\/.*?\/(.*?)\\", a0) '因从第一个“/”开始匹配,或者可写成Mid(reg1("\/.*?\/(.*?)\\", a0), Len(a1) + 1 + 1)
    If a2 <> "" Then
        mTab.Cell(i1, 2).Range.Text = a2
        mTab.Cell(i1, 2 + 1).Range.Text = a1
    End If
    '---
    gototable1 n1, i1, j1
End Sub

以上是关于vbscript 单词add_link的主要内容,如果未能解决你的问题,请参考以下文章

vbscript 单个单词查缩写

vbscript 单词get_title11

vbscript 单词提取

vbscript excel从单词中获取形式

vbscript 单词select_and_cp

“vbscript”查找行有相似的单词用冒号分隔“:”[关闭]