|
详细文件见http://club.excelhome.net/forum.php?mod=viewthread&tid=652638 6楼!非常感谢!
Sub ÅúÁ¿¶ÔWord²Ù×÷()
' ÅúÁ¿É¾³ýҳüҳ½Å²¢ÖØÉèÒ³½Å Macro
' A.¹«¹²²¿·ÖµÄ´úÂë
Application.ScreenUpdating = False '¶³½áÆÁÄ»£¬ÒÔ·ÀÆÁÄ»¶¶¶¯£¬Õâ¾äºÃÏñû×÷Ó㬴°¿ÚÈÔÈ»»á²ü¶¶
Dim mydialog As FileDialog, GetStr(1 To 40) As String '
On Error Resume Next
Set mydialog = Application.FileDialog(msoFileDialogFilePicker)
With mydialog
.Title = "ÇëÑ¡ÔñÒª´¦ÀíµÄÎĵµ(¿É¶àÑ¡)"
.Filters.Clear
.Filters.Add "ËùÓÐWORDÎļþ", "*.docx", 1
.AllowMultiSelect = True
i = 1
If .Show = -1 Then
For Each stiSelectedItem In .SelectedItems
GetStr(i) = stiSelectedItem
i = i + 1
Next
i = i - 1
End If
Application.ScreenUpdating = False
For j = 1 To i Step 1
Set Doc = Documents.Open(FileName:=GetStr(j), Visible:=True)
Windows(GetStr(j)).Activate
' B¿ÉÒÔÌæ»»µÄºê
' ÒÔÏÂÊÇ´¦Àí¸ñʽËù¼ÖƵĺ꣬¿É¸ù¾ÝËùÐè¼ÖÆ
Application.Run MacroName:="Ì滻ҳüÄÚÈÝ" 'ÔËÐÐÃûΪ"Ì滻ҳüÄÚÈÝ"µÄºê£¬ºêÃüÁî¼ûºóÃæ
' ÒÔÉÏ¿ÉÒÔ»»³ÉÊÇÄã×Ô¼ºÂ¼ÖƵĺê
' C¹«¹²²¿·ÖµÄ´úÂë
'Application.Run MacroName:="Macro1"'ÔËÐÐÃûΪ"Macro1"µÄºê£¬¸ù¾ÝÐèҪ¼ÖÆ£¬×ÔÐÐÃüÃû
ActiveDocument.Save '±£´æ
ActiveWindow.Close 'Í˳ö
Next
Application.ScreenUpdating = True
End With
MsgBox "²Ù×÷Íê³É£¬Çë²é¿´£¡£¡", 64, "Ìáʾ"
'Application.Quit '¹Ø±Õ²¢Í˳öWord
End Sub
Sub Ì滻ҳüÄÚÈÝ()
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = " " 'Ðè²éÕÒµÄÄÚÈÝ
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.CorrectHangulEndings = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^l" 'Ðè²éÕÒµÄÄÚÈÝ
.Replacement.Text = "" 'ÒªÌæ»»µÄÄÚÈÝ
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.CorrectHangulEndings = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
End Sub
|
|