|
楼主 |
发表于 2015-5-28 20:33
|
显示全部楼层
前辈好!我录的宏是保存在通用摸板上,你今天给我的代码怎么样才能用,我真是个外行,下面笫一个是我录的。你给的2个我不知怎么用,还劳你教一下详细步骤。谢谢!
Sub Macro1()
'
' Macro1 Macro
' 宏在 2015-5-28 由 User 录制
'
Selection.TypeParagraph
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
With Selection.Find
.Text = "^p "
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
With Selection.Find
.Text = "^p "
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchByte = True
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.Find.Execute Replace:=wdReplaceAll
Selection.WholeStory
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(-2.79)
.RightIndent = CentimetersToPoints(-0.92)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 15.6
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpace1pt5
.Alignment = wdAlignParagraphJustify
.WidowControl = False
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(0.29)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = -5.24
.CharacterUnitFirstLineIndent = 1.65
.LineUnitBefore = 0
.LineUnitAfter = 0
.AutoAdjustRightIndent = True
.DisableLineHeightGrid = False
.FarEastLineBreakControl = True
.WordWrap = True
.HangingPunctuation = True
.HalfWidthPunctuationOnTopOfLine = False
.AddSpaceBetweenFarEastAndAlpha = True
.AddSpaceBetweenFarEastAndDigit = True
.BaseLineAlignment = wdBaselineAlignAuto
End With
With Selection.Font
.NameFarEast = "宋体"
.NameAscii = "宋体"
.NameOther = "宋体"
.Name = "宋体"
.Size = 15
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorBlack
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 1
.Animation = wdAnimationNone
.DisableCharacterSpaceGrid = False
.EmphasisMark = wdEmphasisMarkNone
End With
Selection.HomeKey Unit:=wdStory
Selection.Delete Unit:=wdCharacter, Count:=1
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(-2.79)
.RightIndent = CentimetersToPoints(-0.92)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 15.6
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpace1pt5
.Alignment = wdAlignParagraphCenter
.WidowControl = False
.KeepWithNext = False
.KeepTogether = False
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(0)
.OutlineLevel = wdOutlineLevelBodyText
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = -5.24
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.AutoAdjustRightIndent = True
.DisableLineHeightGrid = False
.FarEastLineBreakControl = True
.WordWrap = True
.HangingPunctuation = True
.HalfWidthPunctuationOnTopOfLine = False
.AddSpaceBetweenFarEastAndAlpha = True
.AddSpaceBetweenFarEastAndDigit = True
.BaseLineAlignment = wdBaselineAlignAuto
End With
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
With Selection.Font
.NameFarEast = "宋体"
.NameAscii = "宋体"
.NameOther = "宋体"
.Name = "宋体"
.Size = 18
.Bold = True
.Italic = False
.Underline = wdUnderlineNone
.UnderlineColor = wdColorAutomatic
.StrikeThrough = False
.DoubleStrikeThrough = False
.Outline = False
.Emboss = False
.Shadow = False
.Hidden = False
.SmallCaps = False
.AllCaps = False
.Color = wdColorRed
.Engrave = False
.Superscript = False
.Subscript = False
.Spacing = 0
.Scaling = 100
.Position = 0
.Kerning = 1
.Animation = wdAnimationNone
.DisableCharacterSpaceGrid = False
.EmphasisMark = wdEmphasisMarkNone
End With
Selection.HomeKey Unit:=wdLine
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(2.54)
.BottomMargin = CentimetersToPoints(2.54)
.LeftMargin = CentimetersToPoints(3.09)
.RightMargin = CentimetersToPoints(2.26)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(1.75)
.PageWidth = CentimetersToPoints(21)
.PageHeight = CentimetersToPoints(29.7)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
.LayoutMode = wdLayoutModeLineGrid
End With
End Sub
Sub Macro2()
'
' Macro2 Macro
' 宏在 2015-5-28 由 User 录制
'
End Sub
Sub BatchChangeColor()
Dim wNum As Long, wDoc As Document
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Filters.Clear
.Filters.Add "Word 文档", "*.doc;*.doc*"
If .Show <> -1 Then Exit Sub
Application.ScreenUpdating = False
For wNum = 1 To .SelectedItems.Count
Set wDoc = Documents.Open(.SelectedItems(wNum), Visible:=False)
With wDoc.Range
End With
wDoc.Close True
Next
Application.ScreenUpdating = True
MsgBox "共完成 " & wNum - 1 & " 个文档!"
End With
End Sub
Sub Macro3()
'
' Macro3 Macro
' 宏在 2015-5-28 由 User 录制
'
End Sub
Sub BatchChangeColor()
Dim wNum As Long, wDoc As Document
With Application.FileDialog(msoFileDialogFilePicker)
.AllowMultiSelect = True
.Filters.Clear
.Filters.Add "Word 文档", "*.doc;*.doc*"
If .Show <> -1 Then Exit Sub
Application.ScreenUpdating = False
For wNum = 1 To .SelectedItems.Count
Set wDoc = Documents.Open(.SelectedItems(wNum), Visible:=False)
With wDoc.Range.Find
With ActiveDocument.Range.Find
.ClearFormatting
.Replacement.ClearFormatting
.Replacement.Font.Color = wdColorBlue
.Execute "^13\<目录\>*^13\<篇名\>*^13", , , True, , , , , , , wdReplaceAll
End With
End With
wDoc.Close True
Next
Application.ScreenUpdating = True
MsgBox "共完成 " & wNum - 1 & " 个文档!"
End With
End Sub
|
|