Tælle antal linier VBA
Er nogen, der har et bud på en stump VBA-kode,der kan tælle antal linier i et Word-dokument,
når dette åbnes efter en brevfletning
og returnere værdien i en variabel eksempel "C"
Kode indtil videre :
____________________
'REM´et
' MsgBox "Der er antal" & "lines"
' B er antal linier TOTALT
'for at kun hver anden linie skal være gråtonet skal der
'selvfølgelig divideres med en faktor 2
'C =ANTAL linier
c = 17
'C divideres med 2 da makroen skal køres B antal gange da den tager to linier ad gangen en grå og en linie unden
' baggrundsfarve..
b = c / 2
For a = 1 To b
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorGray125
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.MoveRight Unit:=wdWord, Count:=4, Extend:=wdExtend
Selection.Shading.Texture = wdTextureNone
Selection.Shading.ForegroundPatternColor = wdColorAutomatic
Selection.Shading.BackgroundPatternColor = wdColorAutomatic
Selection.MoveLeft Unit:=wdWord, Count:=1
Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Next a
End Sub
MVH Martens
