2017-01-21 13 views
-3

Я хочу создать макрос Word, который может выполнить следующую задачу за один клик. Пожалуйста, помогите мне. У меня есть большой документ, это проблема для меня.Я хочу создать макрос Word для форматирования таблицы

Задача включает в себя таблицу форматирования, такие как

таблицу шириной 11 см,
выравнивается по левому краю,
шрифт TNR 10,
границы черный,
отступ слева равен нулю.

+0

OK. Преуспевать. Используйте макрокоманд Word и отформатируйте таблицу (создайте небольшую в другом документе). Когда закончите, прекратите запись и ... Вуаля! У вас есть макрос! Скопируйте его в свой реальный документ, внесите любые изменения в работу с фактической таблицей, и все будет готово. –

ответ

0

Я получил код макроса .... спасибо ..

Sub Macro1()

With Selection.tables(1) 
    .Rows.HeightRule = wdRowHeightAuto 
    .PreferredWidthType = wdPreferredWidthPoints 
    .PreferredWidth = CentimetersToPoints(11) 
End With 


With Selection.Borders(wdBorderTop) 
    .LineStyle = Options.DefaultBorderLineStyle 
    .LineWidth = Options.DefaultBorderLineWidth 
    .Color = Options.DefaultBorderColor 

End With 
With Selection.Borders(wdBorderLeft) 
    .LineStyle = Options.DefaultBorderLineStyle 
    .LineWidth = Options.DefaultBorderLineWidth 
    .Color = Options.DefaultBorderColor 
End With 
With Selection.Borders(wdBorderBottom) 
    .LineStyle = Options.DefaultBorderLineStyle 
    .LineWidth = Options.DefaultBorderLineWidth 
    .Color = Options.DefaultBorderColor 
End With 
With Selection.Borders(wdBorderRight) 
    .LineStyle = Options.DefaultBorderLineStyle 
    .LineWidth = Options.DefaultBorderLineWidth 
    .Color = Options.DefaultBorderColor 
End With 
With Selection.Borders(wdBorderVertical) 
    .LineStyle = Options.DefaultBorderLineStyle 
    .LineWidth = Options.DefaultBorderLineWidth 
    .Color = Options.DefaultBorderColor 
End With 
    With Selection.Borders(wdBorderHorizontal) 
    .LineStyle = Options.DefaultBorderLineStyle 
    .LineWidth = Options.DefaultBorderLineWidth 
    .Color = Options.DefaultBorderColor 
End With 
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft 
With Selection.ParagraphFormat 
    .LeftIndent = CentimetersToPoints(0) 
    .RightIndent = CentimetersToPoints(0) 
    .SpaceBefore = 0 
    .SpaceBeforeAuto = False 
    .SpaceAfter = 0 
    .SpaceAfterAuto = False 
    .LineSpacingRule = wdLineSpaceSingle 
    .Alignment = wdAlignParagraphLeft 
    .WidowControl = True 
    .KeepWithNext = False 
    .KeepTogether = False 
    .PageBreakBefore = False 
    .NoLineNumber = False 
    .Hyphenation = True 
    .FirstLineIndent = CentimetersToPoints(0) 
    .OutlineLevel = wdOutlineLevelBodyText 
    .CharacterUnitLeftIndent = 0 
    .CharacterUnitRightIndent = 0 
    .CharacterUnitFirstLineIndent = 0 
    .LineUnitBefore = 0 
    .LineUnitAfter = 0 
    .MirrorIndents = False 
    .TextboxTightWrap = wdTightNone 
    .CollapsedByDefault = False 
End With 
With Selection.ParagraphFormat 
    .LeftIndent = CentimetersToPoints(0) 
    .RightIndent = CentimetersToPoints(0) 
    .SpaceBefore = 0 
    .SpaceBeforeAuto = False 
    .SpaceAfter = 0 
    .SpaceAfterAuto = False 
    .LineSpacingRule = wdLineSpaceSingle 
    .Alignment = wdAlignParagraphLeft 
    .WidowControl = True 
    .KeepWithNext = False 
    .KeepTogether = False 
    .PageBreakBefore = False 
    .NoLineNumber = False 
    .Hyphenation = True 
    .FirstLineIndent = CentimetersToPoints(0) 
    .OutlineLevel = wdOutlineLevelBodyText 
    .CharacterUnitLeftIndent = 0 
    .CharacterUnitRightIndent = 0 
    .CharacterUnitFirstLineIndent = 0 
    .LineUnitBefore = 0 
    .LineUnitAfter = 0 
    .MirrorIndents = False 
    .TextboxTightWrap = wdTightNone 
    .CollapsedByDefault = False 
End With 

    With Selection.tables(1).Rows 
    .Alignment = wdAlignRowLeft 
    .AllowBreakAcrossPages = True 
    .SetLeftIndent LeftIndent:=CentimetersToPoints(0), RulerStyle:= _ 
     wdAdjustNone 
End With 

End Sub

 Смежные вопросы

  • Нет связанных вопросов^_^