handdator

Visa fullständig version : Behöver hjälp med Macro i Word


Arnesson
2011-04-26, 13:13
Hej,

Har ärvt ett macro i Word från en tidigare kollega som tar en text och gör den till en rubrikrad med hjälp av en tabell.

Ser ut idag

http://i54.tinypic.com/2ytqkwh.jpg

Jag vill
http://i53.tinypic.com/2ciismp.jpg

Jag vill allså ändra höjd och bredd på tabellen. Jag vill att den ska vara 15,45cm bred och 0,63cm hög. Gärna indent from left 0,18cm också.


Jag är ingen kodare, någon som kan hjälpa mig på traven?

Macro i kod
Sub Titel()

Application.ScreenUpdating = False

Selection.Font.Bold = wdToggle
Selection.Font.Color = -603914241
Selection.ConvertToTable Separator:=wdSeparateByParagraphs, NumColumns:=1, _
NumRows:=1, 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.SelectCell
Selection.ParagraphFormat.Alignment = wdAlignParagraphLeft
Selection.Cells.VerticalAlignment = wdCellAlignVerticalCenter
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = -654262273
With Selection.Tables(1)
With .Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -654262273
End With
With .Borders(wdBorderRight)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -654262273
End With
With .Borders(wdBorderTop)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -654262273
End With
With .Borders(wdBorderBottom)
.LineStyle = wdLineStyleSingle
.LineWidth = wdLineWidth050pt
.Color = -654262273
End With
.Borders(wdBorderDiagonalDown).LineStyle = wdLineStyleNone
.Borders(wdBorderDiagonalUp).LineStyle = wdLineStyleNone
.Borders.Shadow = False
End With
With Options
.DefaultBorderLineStyle = wdLineStyleSingle
.DefaultBorderLineWidth = wdLineWidth050pt
.DefaultBorderColor = -654262273
End With
Selection.EndKey Unit:=wdLine, Extend:=wdExtend
Selection.Font.Bold = wdToggle
Selection.MoveLeft Unit:=wdCharacter, Count:=1
'''
''' ------------------------------------------------------
'''

Selection.EndKey Unit:=wdLine, Extend:=wdExtend

Selection.ParagraphFormat.LineSpacing = LinesToPoints(1)
With Selection.ParagraphFormat
.LeftIndent = CentimetersToPoints(0)
.RightIndent = CentimetersToPoints(0)
.SpaceBefore = 0
.SpaceBeforeAuto = False
.SpaceAfter = 0
.SpaceAfterAuto = False
.LineSpacingRule = wdLineSpaceSingle
.Alignment = wdAlignParagraphLeft
.WidowControl = True
.KeepWithNext = True
.KeepTogether = True
.PageBreakBefore = False
.NoLineNumber = False
.Hyphenation = True
.FirstLineIndent = CentimetersToPoints(0)
.OutlineLevel = wdOutlineLevel1
.CharacterUnitLeftIndent = 0
.CharacterUnitRightIndent = 0
.CharacterUnitFirstLineIndent = 0
.LineUnitBefore = 0
.LineUnitAfter = 0
.MirrorIndents = False
.TextboxTightWrap = wdTightNone
End With
Selection.Font.Size = 10
Selection.Font.Name = "Arial"
Selection.MoveLeft Unit:=wdCharacter, Count:=1


Application.ScreenUpdating = True

End Sub

Snafu
2011-04-26, 13:20
Du kan kanske annars recorda det nytt? Developer "record macro", i 2007. Eller så får en ASP nerd svara =)

Arnesson
2011-04-26, 13:41
Du kan kanske annars recorda det nytt? Developer "record macro", i 2007. Eller så får en ASP nerd svara =)

Jag har testat men det gick inget bra. Beror nog mer på mig än Word dock *gah!*