配置我的radiobuttons,以便将文本从UserForm导入书签

问题描述 投票:0回答:1

我正在使用userform执行文档。在userform中,我点击时设置了radiobuttons,我希望将我所做的宏中的文本插入到文档中的特定书签中。请帮忙

这是我的宏:

Sub ordonnance()
'
' ORDONNANCE Macro
'
'
    Dim bmSignet As Bookmark
    Dim rgPlageDuSignet As Range
    Set bmSignet = ActiveDocument.Bookmarks("ORDONNANCE_DE")
    Set rgPlageDuSignet = bmSignet.Range
    rgPlageDuSignet.Select
    ActiveDocument.Tables.Add rgPlageDuSignet, 1, 1
    With Selection.Tables(1)
        If .Style <> "Grille du tableau" Then
            .Style = "Grille du tableau"
        End If
        .ApplyStyleHeadingRows = True
        .ApplyStyleLastRow = False
        .ApplyStyleFirstColumn = True
        .ApplyStyleLastColumn = False
        .ApplyStyleRowBands = True
        .ApplyStyleColumnBands = False
    End With
    Selection.Font.Name = "Arial"
    Selection.Font.Size = 12
    Selection.Font.Bold = wdToggle
    Selection.TypeText Text:="ORDONNANCE DE NON-PUBLICATION ..."

    Set bmSignet = Nothing
    Set rgPlageDuSignet = Nothing

End Sub

这是我的radiobutton:

Private Sub OptionButton3_Click()

    If Me.OptionButton3.Value = True Then
        Call RemplaceSignet("ORDONNANCE_DE", "ORDONNANCE DE NON-PUBLICATION ...")
    Else
        Call RemplaceSignet("ORDONNANCE_DE", " ")
   End If
End Sub
vba ms-word bookmarks
1个回答
0
投票

尝试:

Sub ordonnance(StrBkMk As String, StrTxt As String)
'
' ORDONNANCE Macro
'
'
Dim Tbl As Table
With ActiveDocument
  Set Tbl = .Tables.Add(.Bookmarks(StrBkMk).Range, 1, 1)
  With Tbl
    .Style = "Grille du tableau"
    .ApplyStyleHeadingRows = True
    .ApplyStyleLastRow = False
    .ApplyStyleFirstColumn = True
    .ApplyStyleLastColumn = False
    .ApplyStyleRowBands = True
    .ApplyStyleColumnBands = False
    With .Cell(1, 1).Range
      With .Font
        .Name = "Arial"
        .Size = 12
        .Bold = True
      End With
      .Text = StrTxt
    End With
  End With
End With
Set Tbl = Nothing
End Sub

请注意,无需选择任何内容。

© www.soinside.com 2019 - 2024. All rights reserved.