fExcel贴数
197 字
1 分钟
fExcel贴数
fExcel贴数
Sub 粘贴格式文本(control As IRibbonControl) Set xl = GetObject(, "excel.application") xlr = xl.Selection.Rows.Count xlc = xl.Selection.Columns.Count With Selection wdc = .Information(16) wdr = .Information(13) rangeselect wdr, wdc, xlr, xlc ReDim arr(1 To 1) For Each sht In .Cells i = i + 1 ReDim Preserve arr(1 To i) arr(i) = sht.Range.Font.Underline Next .CopyFormat .PasteAndFormat (wdFormatSurroundingFormattingWithEmphasis) .PasteFormat With .Find .Text = " " .Replacement.Text = "" .Forward = True .Wrap = wdFindStop .Execute Replace:=wdReplaceAll End With rangeselect wdr, wdc, xlr, xlc For Each sht In .Cells j = j + 1 sht.Range.Font.Underline = arr(j) Next End With
End SubSub 双下划线(control As IRibbonControl) If Selection.Font.Underline = wdUnderlineDouble Then Selection.Font.Underline = wdUnderlineNone ElseIf Selection.Font.Underline = wdUnderlineNone Then Selection.Font.Underline = wdUnderlineDouble End IfEnd SubSub 单下划线(control As IRibbonControl) If Selection.Font.Underline = wdUnderlineSingle Then Selection.Font.Underline = wdUnderlineNone ElseIf Selection.Font.Underline = wdUnderlineNone Then Selection.Font.Underline = wdUnderlineSingle End IfEnd SubFunction rangeselect(wdr, wdc, xlr, xlc) With Selection .Tables(1).Cell(wdr, wdc).Select .Collapse wdCollapseStart st = .Start .Tables(1).Cell(wdr + xlr - 1, wdc + xlc - 1).Select .Collapse wdCollapseEnd ed = .End ActiveDocument.Range(st, ed).Select End WithEnd Function支持与分享
如果这篇文章对你有帮助,欢迎分享给更多人或打赏支持!
相关文章智能推荐
1
【VBA案例001】实现VLOOKUP功能
程技2023-10-23
2
【VBA案例002】一对多查询
程技2023-10-23
3
【VBA案例003】模糊查询
程技2023-10-23
4
【VBA案例004】自动填充表单
程技2023-10-23
5
【VBA案例005】自动汇总表单
程技2023-10-23
随机文章随机推荐
樊笼










