Programmation vb

Disponible uniquement sur Etudier
  • Pages : 10 (2365 mots )
  • Téléchargement(s) : 0
  • Publié le : 11 avril 2011
Lire le document complet
Aperçu du document
Les programmes suivants se trouvent dans Module1

' Option Explicit
Sub Liste_les_commandes()
Application.ListCommands ListAllCommands:=True
End Sub
Sub sel0()
'Dim sel As Selection
'Set sel = Application.Selection
'MsgBox sel
'MsgBox Application.Selection
MsgBox Selection
End Sub
Sub sel1()
Dim i
Dim sel As Selection
Set sel = Application.Selection
MsgBox sel
For i = 1 To 4sel.MoveRight unit:=wdCharacter, Count:=1
MsgBox sel
'sel.MoveRight unit:=wdWord, Count:=1
'sel.MoveRight unit:=wdSentence, Count:=1, Extend:=wdExtend
'sel.Moveright unit:=wdParagraph, Count:=1
'sel.Moveright unit:=wdLine, Count:=1
'sel.MoveRight unit:=wdStory, Count:=1
'sel.MoveRight unit:=wdCharacter, Count:=1
'sel.MoveRight unit:=wdWord, Count:=1
'sel.MoveLeft unit:=wdWord, Count:=1,Extend:=wdExtend
'sel.Moveright unit:=wdParagraph, Count:=1
'sel.Moveright unit:=wdLine, Count:=1
'sel.MoveRight unit:=wdStory, Count:=1
MsgBox i
Next

Selection.HomeKey unit:=wdLine
Selection.MoveRight unit:=wdWord, Count:=3
Selection.EndKey unit:=wdLine
Selection.MoveLeft unit:=wdWord, Count:=2
Selection.MoveUp unit:=wdLine, Count:=1
Selection.MoveDownunit:=wdLine, Count:=1

End Sub
Sub sel2()
Dim sel As Selection
Set sel = Application.Selection
sel.MoveLeft unit:=wdStory, Count:=1
End Sub
Sub plage0()
Dim plage As Range
Set plage = ActiveDocument.Range(Start:=10, End:=110)
plage.Select
End Sub
Sub plage1()
Dim plage As Range
Set plage = ActiveDocument.Range(Start:=0, End:=ActiveDocument.Characters.Count)
plage.Select
End Sub
Subplage2()
Dim plage As Range
Set plage = ActiveDocument.Range
plage.WholeStory
plage.Select
End Sub
Sub plage3()
MsgBox ActiveDocument.Characters(ActiveDocument.Characters.Count)
MsgBox ActiveDocument.Characters(ActiveDocument.Characters.Count - 1)
End Sub
Sub plage4()
Dim plage As Range
Set plage = ActiveDocument.Range
plage.Expand unit:=wdStory
End Sub
Sub plage5()
Dim plage As RangeSet plage = ActiveDocument.Range(Start:=0, End:=0)
plage.Select
End Sub
Sub plage6()
Dim plage As Range
Set plage = ActiveDocument.Range(Start:=175, End:=175)
plage.Select
MsgBox test
plage.Expand unit:=wdCharacter 'caractère
plage.Select
MsgBox test
plage.Expand unit:=wdWord 'mot
plage.Select
MsgBox test
plage.Expand unit:=wdSentence ' phrase
plage.Select
MsgBox test
plage.Expandunit:=wdParagraph ' paragraphe
plage.Select
MsgBox test
plage.Expand unit:=wdStory ' texte entier
plage.Select
End Sub
Sub plage7()
Dim plage As Range
Set plage = ActiveDocument.Paragraphs(5).Range
plage.Bold = True
End Sub
Sub plage8()
ActiveDocument.Paragraphs(5).Range.Bold = True
End Sub
Sub plage9()
Dim plage As Range
Set plage =ActiveDocument.Range(Start:=ActiveDocument.Paragraphs(3).Range.Start, _
End:=ActiveDocument.Paragraphs(7).Range.End)
plage.Select
End Sub
Sub plage10()
Dim plage As Range
Set plage = ActiveDocument.Paragraphs(5).Range
MsgBox (plage.ComputeStatistics(wdStatisticCharactersWithSpaces))
End Sub

Sub plage11()
Dim plage As Range
Set plage = Selection.Paragraphs(1).Range
MsgBox(plage.ComputeStatistics(wdStatisticCharactersWithSpaces))
End Sub
Sub plage12()
Dim plage1 As Range
Dim plage2 As Range
Set plage1 = Selection.Paragraphs(1).Range
plage1.Select
plage1.Copy
Set plage2 = ActiveDocument.Range(Start:=plage1.End, End:=plage1.End)
plage2.Select
MsgBox test
plage2.Paste
plage2.Paste
plage2.Paste
plage2.Paste
End Sub

Sub plage13()
Dim plage As Range
Set plage = ActiveDocument.Range
plage.Select
End SubSub plage14()
Dim plage As Range
Set plage = ActiveDocument.Content
plage.Select
End Sub
Sub listphra()
Dim phrase
For Each phrase In ActiveDocument.Sentences
MsgBox phrase
Next

End Sub
Sub listcar()
Dim i
For i = 1 To ActiveDocument.Characters.Count
MsgBox ActiveDocument.Characters(i)
Next
End Sub
Sub listdoc()
Dim i
For i = 1 To Documents.Count
MsgBox Documents(i).Name +...
tracking img