|
本帖最后由 信合小干事 于 2013-11-7 09:30 编辑
预想效果图
各位高手不好意思,又打搅你们了,为了实行word按照宏模式自动排版,我录制了一个宏(手工编写不会,没有一点基础),全部是按照手工"Ctrl+H"制作的,在制作时,能出来我的预想效果,但是执行宏之后就与理想不同了。
问题:
我的预想效果图是图片所呈现的(灰色部分),“第X章,第X条,(X),正文仿宋三号字体,无边框”等设置,但是执行宏后,只有“第X章”这部分是正确的,不同的是:全文字体是自带模板的字体,文章四周带边框,第X条没有加粗“,不知道出现了什么情况,请高手看看。
通过这回学习,我发现是不是我的宏太繁琐了?
辛苦各位了!
录制宏.rar
(5.11 KB, 下载次数: 27)
[code=vb]Sub 公文 ()'' 公文Macro' 宏在 2013/11/7 由 USER 录制' Application.WindowState = wdWindowStateNormal Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "^p" .Replacement.Text = "" .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.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "-*-" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll 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(2.9) .RightMargin = CentimetersToPoints(2.9) .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 Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find.Replacement.ParagraphFormat .SpaceBeforeAuto = False .SpaceAfterAuto = False .Alignment = wdAlignParagraphLeft .WordWrap = True End With Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False With Selection.Find .Text = "*" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find .Text = "第[!章]{1,5}章" .Replacement.Text = "^p^&" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "第[!条]{1,5}条" .Replacement.Text = "^p^&" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Find .Text = "([!含])" .Replacement.Text = "^p^&" .Forward = True .Wrap = wdFindContinue .Format = False .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting Selection.Find.Replacement.Style = ActiveDocument.Styles("标题 2") Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False With Selection.Find .Text = "第[!章]{1,5}章" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll Selection.Find.ClearFormatting Selection.Find.Style = ActiveDocument.Styles("标题 2") Selection.Find.ParagraphFormat.Borders.Shadow = False Selection.Find.Replacement.ClearFormatting With Selection.Find.Replacement.ParagraphFormat .SpaceBeforeAuto = False .SpaceAfterAuto = False .Alignment = wdAlignParagraphCenter .WordWrap = True End With Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False With Selection.Find .Text = "*" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll ActiveWindow.ActivePane.VerticalPercentScrolled = 64 Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find.Replacement.ParagraphFormat .SpaceBeforeAuto = False .SpaceAfterAuto = False .FirstLineIndent = CentimetersToPoints(0.35) .CharacterUnitFirstLineIndent = 2 .WordWrap = True End With Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False With Selection.Find .Text = "第[!条]{1,5}条" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End With Selection.Find.Execute Replace:=wdReplaceAll With Selection.Font .Borders(1).LineStyle = wdLineStyleNone .Borders.Shadow = False End With With Options .DefaultBorderLineStyle = wdLineStyleSingle .DefaultBorderLineWidth = wdLineWidth050pt .DefaultBorderColor = wdColorAutomatic End With Selection.Find.ClearFormatting Selection.Find.Replacement.ClearFormatting With Selection.Find.Replacement.ParagraphFormat .SpaceBeforeAuto = False .SpaceAfterAuto = False .FirstLineIndent = CentimetersToPoints(0.35) .CharacterUnitFirstLineIndent = 2 .WordWrap = True End With Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False With Selection.Find .Text = "第[!条]{1,5}条" .Replacement.Text = "" .Forward = True .Wrap = wdFindContinue .Format = True .MatchCase = False .MatchWholeWord = False .MatchByte = False .MatchAllWordForms = False .MatchSoundsLike = False .MatchWildcards = True End WithEnd Sub[/code]
|
|