Stap 5: Code aap!
1) deze code maakt het zo als ooit de persoon met behulp van woord typen E het document zonder op te slaan sluit. De code is
Sub AddKeyBinding()
CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeyE), KeyCategory: = wdKeyCategoryCommand, _
Opdracht: = "TestKeybinding"
End Sub
Sub TestKeybinding()
Dim x As Document
Set x = ActiveDocument
x.Close (False)
End Sub
2) deze prank maakt vaak verkeerd gespelde woorden worden correct weergegeven, zodat geen rode lijn eronder verschijnt.
Sub AutoExec()
Oproep WriteToATextFile
Dim dicCustom als woordenboek
Set dicCustom = Application.CustomDictionaries _
. Add(filename:="c:\customdic5.dic")
Application.CustomDictionaries.ActiveCustomDictionary = dicCustom
Met applicatie
CustomizationContext = NormalTemplate
KeyBindings.Add KeyCode:=BuildKeyCode(wdKeySpacebar), KeyCategory: = wdKeyCategoryCommand, _
Opdracht: = "spellit"
Eindigen met
End Sub
Sub WriteToATextFile()
MyFile = "c:\customdic5.dic"
fnum = FreeFile()
Open MyFile voor uitvoer als fnum
Afdrukken van #fnum, "de"
Afdrukken van #fnum, 'Teh'
#fnum sluiten
End Sub
Public Sub spellit()
Selection.TypeText tekst: = ""
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Met Selection.Find
. Tekst = "de"
. Replacement.Text = "de"
. Voorwaarts = True
. Wikkel = wdFindContinue
. Indeling = False
. MatchCase = True
. MatchWholeWord = False
. MatchWildcards = False
. MatchSoundsLike = False
. MatchAllWordForms = False
Eindigen met
Selection.Find.Execute vervangen: = wdReplaceAll
Selection.Find.ClearFormatting
Selection.Find.Replacement.ClearFormatting
Met Selection.Find
. Tekst = "De"
. Replacement.Text = "Teh"
. Voorwaarts = True
. Wikkel = wdFindContinue
. Indeling = False
. MatchCase = True
. MatchWholeWord = False
. MatchWildcards = False
. MatchSoundsLike = False
. MatchAllWordForms = False
Eindigen met
Selection.Find.Execute vervangen: = wdReplaceAll
End Sub
3) deze prank maakt zweert willekeurig verschijnen terwijl de persoon aan het typen is.
Sub typeRand()
Dim counter As String
Counter = CStr (Int ((30-1 + 1) * Rnd + 1))
Application.OnTime wanneer: = nu + TimeValue ("00:00:" + counter), _
Naam: = "TimedClose"
End Sub
Sub TimedClose()
Dim maindocument As Document
Set maindocument = activedocument
Counter = CStr (Int ((5-1 + 1) * Rnd + 1))
Select Case teller
Geval 1
Selection.TypeText tekst: = ""
Case 2
Selection.TypeText tekst: = ""
Case 3
Selection.TypeText tekst: = ""
Zaak 4
Selection.TypeText tekst: = ""
Geval 5
Selection.TypeText tekst: = ""
Einde selecteren
Oproep typeRand
End Sub