返回列表 上一主題 發帖

[發問] 用Excel開啟word後的搜尋問題

回復 4# PKKO
試試看
  1. Option Explicit
  2. Sub Ex()
  3.     Dim s As String, n As Integer
  4.     s = "TEST"
  5.     With Selection.Find
  6.         .Text = s
  7.         .Replacement.Text = ""
  8.         .Forward = True
  9.         .Wrap = wdFindContinue
  10.         .Format = False
  11.         .MatchCase = False
  12.         .MatchWholeWord = False
  13.         .MatchByte = True
  14.         .MatchWildcards = False
  15.         .MatchSoundsLike = False
  16.         .MatchAllWordForms = False
  17.     End With
  18.     Do While Selection.Find.Execute = True
  19.         n = n + 1
  20.         Selection.Find.Execute
  21.     Loop
  22.     If n > 0 Then
  23.         MsgBox "搜尋 " & s & " 共有 " & n & " 次"
  24.     Else
  25.         MsgBox "搜尋不到 " & s
  26.     End If
  27. End Sub
複製代碼
感恩的心......(在麻辣家族討論區.用心學習會有進步的)
但資源無限,後援有限,  一天1元的贊助,人人有能力.

TOP

        靜思自在 : 我們要做好社會的環保,也要做好內心的環保。
返回列表 上一主題