![]() |
#1
|
|||
|
|||
![]()
Please see the macro I made. Can you please fix it?
Sub A4() ' ' A4 Macro ' ' Selection.WholeStory With ActiveDocument.Styles(wdStyleNormal).Font If .NameFarEast = .NameAscii Then .NameAscii = "" End If .NameFarEast = "" End With With ActiveDocument.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = MillimetersToPoints(13) .BottomMargin = MillimetersToPoints(7) .LeftMargin = MillimetersToPoints(25) .RightMargin = MillimetersToPoints(10) .Gutter = MillimetersToPoints(0) .HeaderDistance = MillimetersToPoints(13) .FooterDistance = MillimetersToPoints(7) .PageWidth = MillimetersToPoints(210) .PageHeight = MillimetersToPoints(297) .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 End With With Selection.PageSetup .LineNumbering.Active = False .Orientation = wdOrientPortrait .TopMargin = MillimetersToPoints(13) .BottomMargin = MillimetersToPoints(7) .LeftMargin = MillimetersToPoints(25) .RightMargin = MillimetersToPoints(10) .Gutter = MillimetersToPoints(0) .HeaderDistance = MillimetersToPoints(13) .FooterDistance = MillimetersToPoints(7) .PageWidth = MillimetersToPoints(210) .PageHeight = MillimetersToPoints(297) .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 End With If ActiveWindow.View.SplitSpecial <> wdPaneNone Then ActiveWindow.Panes(2).Close End If If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ ActivePane.View.Type = wdOutlineView Then ActiveWindow.ActivePane.View.Type = wdPrintView End If ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader Selection.WholeStory Selection.Cut ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=3, NumColumns:= _ 1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitFixed With Selection.Tables(1) If .Style <> "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = False .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = False .ApplyStyleRowBands = True .ApplyStyleColumnBands = False End With Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.MoveDown Unit:=wdLine, Count:=2, Extend:=wdExtend Selection.InsertColumns Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Tables(1).Rows.LeftIndent = MillimetersToPoints(-4) Selection.Tables(1).PreferredWidthType = wdPreferredWidthPoints Selection.Tables(1).PreferredWidth = MillimetersToPoints(180) With Selection.Tables(1) .TopPadding = MillimetersToPoints(0) .BottomPadding = MillimetersToPoints(0) .LeftPadding = MillimetersToPoints(1) .RightPadding = MillimetersToPoints(1) .Spacing = 0 .AllowPageBreaks = True .AllowAutoFit = False End With Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.Cells.Merge Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Collapse Direction:=wdCollapseStart Selection.Move Unit:=wdColumn, Count:=-1 Selection.SelectColumn Selection.Collapse Direction:=wdCollapseStart Selection.Move Unit:=wdColumn, Count:=-1 Selection.SelectColumn Selection.Columns.PreferredWidthType = wdPreferredWidthPoints Selection.Columns.PreferredWidth = MillimetersToPoints(93.6) Selection.Move Unit:=wdColumn, Count:=1 Selection.SelectColumn Selection.Columns.PreferredWidthType = wdPreferredWidthPoints Selection.Columns.PreferredWidth = MillimetersToPoints(86.4) Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.SplitTable Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Tables(1).Columns(1).PreferredWidthType = wdPreferredWidthPoints Selection.Tables(1).Columns(1).PreferredWidth = MillimetersToPoints(137.6) Selection.Move Unit:=wdColumn, Count:=1 Selection.SelectColumn Selection.Columns.PreferredWidthType = wdPreferredWidthPoints Selection.Columns.PreferredWidth = MillimetersToPoints(42.4) Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=1 Selection.InsertRowsAbove 1 Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend Selection.Cut Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveUp Unit:=wdLine, Count:=2, Extend:=wdExtend Selection.Font.Size = 11 Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=2 Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend With Selection.ParagraphFormat .LeftIndent = MillimetersToPoints(0) .RightIndent = MillimetersToPoints(0) .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 1 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpaceSingle .Alignment = wdAlignParagraphLeft .WidowControl = True .KeepWithNext = False .KeepTogether = False .PageBreakBefore = False .NoLineNumber = False .Hyphenation = True .FirstLineIndent = MillimetersToPoints(0) .OutlineLevel = wdOutlineLevelBodyText .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0 .MirrorIndents = False .TextboxTightWrap = wdTightNone .CollapsedByDefault = False End With Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 With Selection.ParagraphFormat .LeftIndent = MillimetersToPoints(0) .RightIndent = MillimetersToPoints(0) .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 12 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpaceSingle .Alignment = wdAlignParagraphLeft .WidowControl = True .KeepWithNext = False .KeepTogether = False .PageBreakBefore = False .NoLineNumber = False .Hyphenation = True .FirstLineIndent = MillimetersToPoints(0) .OutlineLevel = wdOutlineLevelBodyText .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0 .MirrorIndents = False .TextboxTightWrap = wdTightNone .CollapsedByDefault = False End With Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCell Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend With Selection.ParagraphFormat .LeftIndent = MillimetersToPoints(0) .RightIndent = MillimetersToPoints(0) .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 1 .SpaceAfterAuto = False .Alignment = wdAlignParagraphLeft .WidowControl = True .KeepWithNext = False .KeepTogether = False .PageBreakBefore = False .NoLineNumber = False .Hyphenation = True .FirstLineIndent = MillimetersToPoints(0) .OutlineLevel = wdOutlineLevelBodyText .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0.2 .MirrorIndents = False .TextboxTightWrap = wdTightNone .CollapsedByDefault = False End With Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend With Selection.ParagraphFormat .LeftIndent = MillimetersToPoints(0) .RightIndent = MillimetersToPoints(0) .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 1 .SpaceAfterAuto = False .Alignment = wdAlignParagraphLeft .WidowControl = True .KeepWithNext = False .KeepTogether = False .PageBreakBefore = False .NoLineNumber = False .Hyphenation = True .FirstLineIndent = MillimetersToPoints(0) .OutlineLevel = wdOutlineLevelBodyText .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0 .MirrorIndents = False .TextboxTightWrap = wdTightNone .CollapsedByDefault = False End With Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=1, Extend:=wdExtend With Selection.ParagraphFormat .LeftIndent = MillimetersToPoints(0) .RightIndent = MillimetersToPoints(0) .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 1 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpaceSingle .Alignment = wdAlignParagraphLeft .WidowControl = True .KeepWithNext = False .KeepTogether = False .PageBreakBefore = False .NoLineNumber = False .Hyphenation = True .FirstLineIndent = MillimetersToPoints(0) .OutlineLevel = wdOutlineLevelBodyText .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0 .MirrorIndents = False .TextboxTightWrap = wdTightNone .CollapsedByDefault = False End With Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=1 Selection.MoveDown Unit:=wdLine, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend With Selection.Tables(1) .TopPadding = MillimetersToPoints(0) .BottomPadding = MillimetersToPoints(0) .LeftPadding = MillimetersToPoints(1) .RightPadding = MillimetersToPoints(1) .Spacing = 0 .AllowPageBreaks = True .AllowAutoFit = False End With Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveUp Unit:=wdLine, Count:=2 With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone .Borders(wdBorderTop).LineStyle = wdLineStyleNone With .Borders(wdBorderBottom) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .Color = wdColorAutomatic End With .Borders(wdBorderHorizontal).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone .Borders.Shadow = False End With With Options .DefaultBorderLineStyle = wdLineStyleSingle .DefaultBorderLineWidth = wdLineWidth050pt .DefaultBorderColor = wdColorAutomatic End With Selection.InlineShapes.AddPicture FileName:= _ "Y:\MNLGSCBSI\GBU Sustainability\01 Documentation & Control Management\05 MD-MNL Users\22 Jade\MD Macro.png" _ , LinkToFile:=False, SaveWithDocument:=True Selection.MoveRight Unit:=wdCharacter, Count:=4 Selection.Font.Italic = wdToggle Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.TypeText Text:= _ "MAERSK INTEGRATOR - MODU Operations Manual - Volume 2" Selection.MoveRight Unit:=wdCharacter, Count:=3 Selection.ParagraphFormat.Alignment = wdAlignParagraphRight Selection.Font.Italic = wdToggle Selection.TypeText Text:="002 / FEB 2016" Selection.MoveRight Unit:=wdCharacter, Count:=2 Selection.TypeParagraph ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument If ActiveWindow.View.SplitSpecial <> wdPaneNone Then ActiveWindow.Panes(2).Close End If If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ ActivePane.View.Type = wdOutlineView Then ActiveWindow.ActivePane.View.Type = wdPrintView End If ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:= _ 1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:= _ wdAutoFitFixed With Selection.Tables(1) If .Style <> "Table Grid" Then .Style = "Table Grid" End If .ApplyStyleHeadingRows = True .ApplyStyleLastRow = False .ApplyStyleFirstColumn = True .ApplyStyleLastColumn = False .ApplyStyleRowBands = True .ApplyStyleColumnBands = False End With Selection.Tables(1).PreferredWidthType = wdPreferredWidthPoints Selection.Tables(1).PreferredWidth = MillimetersToPoints(175) Selection.Cells.Split NumRows:=1, NumColumns:=2, MergeBeforeSplit:=False Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.Collapse Direction:=wdCollapseStart Selection.Move Unit:=wdColumn, Count:=-1 Selection.SelectColumn Selection.Collapse Direction:=wdCollapseStart Selection.Move Unit:=wdColumn, Count:=-1 Selection.SelectColumn Selection.Columns.PreferredWidthType = wdPreferredWidthPoints Selection.Columns.PreferredWidth = MillimetersToPoints(142.5) Selection.Move Unit:=wdColumn, Count:=1 Selection.SelectColumn Selection.Columns.PreferredWidthType = wdPreferredWidthPoints Selection.Columns.PreferredWidth = MillimetersToPoints(32.5) With Selection.Tables(1) .TopPadding = MillimetersToPoints(0) .BottomPadding = MillimetersToPoints(0) .LeftPadding = MillimetersToPoints(0) .RightPadding = MillimetersToPoints(0) .Spacing = 0 .AllowPageBreaks = True .AllowAutoFit = False End With Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.MoveRight Unit:=wdCharacter, Count:=2, Extend:=wdExtend Selection.Font.Size = 11 With Selection.ParagraphFormat .LeftIndent = MillimetersToPoints(0) .RightIndent = MillimetersToPoints(0) .SpaceBefore = 0 .SpaceBeforeAuto = False .SpaceAfter = 1 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpaceSingle .Alignment = wdAlignParagraphLeft .WidowControl = True .KeepWithNext = False .KeepTogether = False .PageBreakBefore = False .NoLineNumber = False .Hyphenation = True .FirstLineIndent = MillimetersToPoints(0) .OutlineLevel = wdOutlineLevelBodyText .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0 .MirrorIndents = False .TextboxTightWrap = wdTightNone .CollapsedByDefault = False End With Selection.MoveLeft Unit:=wdCharacter, Count:=1 Selection.TypeText Text:="ID: " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "FILENAME ", PreserveFormatting:=True Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend Selection.Font.Italic = wdToggle Selection.MoveRight Unit:=wdCharacter, Count:=2 With Selection.ParagraphFormat .LeftIndent = MillimetersToPoints(0) .RightIndent = MillimetersToPoints(0) .SpaceBefore = 1 .SpaceBeforeAuto = False .SpaceAfter = 0 .SpaceAfterAuto = False .LineSpacingRule = wdLineSpaceSingle .Alignment = wdAlignParagraphLeft .WidowControl = True .KeepWithNext = False .KeepTogether = False .PageBreakBefore = False .NoLineNumber = False .Hyphenation = True .FirstLineIndent = MillimetersToPoints(0) .OutlineLevel = wdOutlineLevelBodyText .CharacterUnitLeftIndent = 0 .CharacterUnitRightIndent = 0 .CharacterUnitFirstLineIndent = 0 .LineUnitBefore = 0 .LineUnitAfter = 0 .MirrorIndents = False .TextboxTightWrap = wdTightNone .CollapsedByDefault = False End With Selection.ParagraphFormat.Alignment = wdAlignParagraphRight If ActiveWindow.View.SplitSpecial <> wdPaneNone Then ActiveWindow.Panes(2).Close End If If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ ActivePane.View.Type = wdOutlineView Then ActiveWindow.ActivePane.View.Type = wdPrintView End If ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter Selection.MoveRight Unit:=wdCharacter, Count:=14 Selection.TypeText Text:="Page " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "PAGE ", PreserveFormatting:=True Selection.TypeText Text:=" / " Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, Text:= _ "NUMPAGES ", PreserveFormatting:=True With Selection.Tables(1) .Borders(wdBorderLeft).LineStyle = wdLineStyleNone .Borders(wdBorderRight).LineStyle = wdLineStyleNone With .Borders(wdBorderTop) .LineStyle = wdLineStyleSingle .LineWidth = wdLineWidth050pt .Color = wdColorAutomatic End With .Borders(wdBorderBottom).LineStyle = wdLineStyleNone .Borders(wdBorderVertical).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone .Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone .Borders.Shadow = False End With With Options .DefaultBorderLineStyle = wdLineStyleSingle .DefaultBorderLineWidth = wdLineWidth050pt .DefaultBorderColor = wdColorAutomatic End With ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument End Sub |
#2
|
||||
|
||||
![]()
It's a bit rich posting 500 lines of unformatted code and asking us to fix it when you haven't bothered saying what's wrong. Please edit your post to:
a) tell us what needs fixing; and b) replace your unformatted code, using the code tags (inserted via the # symbol on the advanced menu) to retain your code formatting.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
![]() |
Tags |
debugging, macro in word |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
Snaybot | Excel Programming | 1 | 11-12-2015 02:02 PM |
![]() |
MacroMess | Word VBA | 6 | 06-05-2015 09:48 AM |
![]() |
LadyAna | Word | 1 | 12-06-2014 10:39 PM |
Macro Needed to bold specific lines and Macro to turn into CSV | anewteacher | Word VBA | 1 | 05-28-2014 03:59 PM |
custom icon, undo/redo for macro, permanent macro | Rapier | Excel | 0 | 08-05-2013 06:30 AM |