Auto-Typing in MS Word with .NET!
This code opens MS Word, creates a new document, and starts writing a text in it letter by letter.Just create a new proyect, a normal windows aplication, add a reference to Microsoft Word Object Library, and copy/paste this code. Then set form opacity to 0%. Easy to implement and Cool effect, isn't?
AI
AI 요약: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.
소스 코드
'Message that will appear in MS Word Private Shared message As String = "Hey, How are you doing?" 'Variable to iterate Private Shared i As Integer 'Timer Object Private Shared WithEvents temp As New Timer() 'Word Objects: application object and document object Private Shared aplicationword As New Word.Application() Private Shared documentword As New Word.Document() 'Boolean variable to escape of while loop Private Shared exiting As Boolean = True Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load 'Word is visible and activate aplicationword.Visible = True aplicationword.Activate() 'One document added to Word documentword = aplicationword.Documents.Add 'Added an event handler AddHandler temp.Tick, AddressOf TimerEventProcessor 'Setting timer properties (delay) temp.Interval = 350 'Yeah!, let's go temp.Start() i = 0 While exiting = False Application.DoEvents() End While End Sub Private Shared Sub TimerEventProcessor(ByVal sender As Object, ByVal e As System.EventArgs) 'If I've finished writting If i = message.Length Then temp.Stop() exiting = True Exit Sub End If 'else writes a new letter aplicationword.Selection.TypeText(message.Chars(i)) i += 1 End Sub
원본 댓글 (3)
Wayback Machine에서 복구됨