Just nu i M3-nätverket
Jump to content

numrerad lista funkar ej med mitt makro, word 2007


Matisyahu

Recommended Posts

Har gjort ett litet makro för första gången. Problemet är att numreringen funkar inte som den ska. Makrot skriver 2 rader, och numreringen fortsätter på den 2a raden då detta är en underrubrik till den första raden. så här ser det makrot ut:

Sub Makro3()
'
' Makro3 Makro
'
'
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="Rubrik"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeText Text:=vbTab
Selection.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(12.25 _
), Alignment:=wdAlignTabLeft, Leader:=wdTabLeaderSpaces
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="namn"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.TypeParagraph
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
PreserveFormatting:=False
Selection.TypeText Text:="underrubrik"
Selection.MoveRight Unit:=wdCharacter, Count:=2
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveLeft Unit:=wdWord, Count:=1, Extend:=wdExtend
End Sub 

Link to comment
Share on other sites

jag fick hjälp på annat håll. men så här ser makrot ut för den fungerande numreringen

 

Sub Makro10()

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
Selection.TypeText Text:="Rubrik"

Selection.EndKey Unit:=wdLine
Selection.ParagraphFormat.TabStops.Add Position:=CentimetersToPoints(16), Alignment:=wdAlignTabRight, Leader:=wdTabLeaderSpaces
Selection.TypeText Text:=vbTab

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
Selection.TypeText Text:="Skriv ditt namn"

Selection.EndKey Unit:=wdLine

With ListGalleries(wdNumberGallery).ListTemplates(7).ListLevels(1)
.NumberFormat = "%1."
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleArabic
.NumberPosition = CentimetersToPoints(0.63)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(1.27)
.TabPosition = wdUndefined
.ResetOnHigher = 0
.StartAt = 1
.LinkedStyle = ""
End With

ListGalleries(wdNumberGallery).ListTemplates(7).Name = ""
Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:=ListGalleries(wdNumberGallery).ListTemplates(7), ContinuePreviousList:=True, ApplyTo:=wdListApplyToWholeList, DefaultListbehavior:=wdWord10Listbehavior
Selection.TypeText Text:=Chr(11)

Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, PreserveFormatting:=False
Selection.TypeText Text:="Underrubrik"

Selection.EndKey Unit:=wdLine
Selection.TypeParagraph
Selection.Range.ListFormat.RemoveNumbers NumberType:=wdNumberParagraph
Selection.MoveUp Unit:=wdLine, Count:=2
Selection.NextField.Select

End Sub 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.



×
×
  • Create New...