您好
我有一WORD檔 ,表格內(用虛線代替)有公司名 + TEL + 地址, 格子寬度只能200寬,
因有些地址長度太長,如下面的[ADRS].....[ADRE] (超過表格寬度),目前都是用手動
將文字反白然後改變字距,讓地址長度縮小,讓地址在表格中都在同一行,
目前有用巨集+快速鍵,但都只能一筆一筆處理,很慢.
請問如何利用VBA巨集,一次就可以把所有[ADRS].....[ADRE]的範為做字距改變?
謝謝!
某B企業有限公司
222[ADRS]桃園縣1111111號[ADRE]
Tel.03-22222
試試看
執行時游標要在文件最前(上)面
<pre class="c" name="code">
Sub iTHelpIsGood()
'
'--搜尋 [ADRS] 字串
Selection.Find.ClearFormatting
With Selection.Find
.Text = "[ADRS]"
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindAsk
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = False
.MatchFuzzy = False
End With
'--如果找得到的話, 就將字體間距縮小
'--如果找不到的話, 就結束執行
Do While Selection.Find.Execute
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
With Selection.Font
.NameFarEast = "新細明體"
.NameAscii = "Times New Roman"
.NameOther = "Times New Roman"
.Name = ""
.Size = 12
.Bold = False
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorAutomatic
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = -1
.Scaling = 100
.Position = 0
.Kerning = 1
.Animation = wdAnimationNone
.DisableCharacterSpaceGrid = False
.EmphasisMark = wdEmphasisMarkNone
End With
Selection.MoveDown Unit:=wdLine, Count:=1
Loop
End Sub