If you want to create a macro that will copy the contents of a text file to your current document, follow the codes below.
Private Sub Document_Open()
Dim mFileName As String
Dim buffer As String
mFileName = "C:\macfiles\MacroLabs.txt"
Open mFileName For Input As #1
Do While Not EOF(1) ' loop in the file while there's something to read
Line Input #1, buffer ' read a line of text and assign it to variable buffer
Selection.TypeText buffer
Loop
Close #1
End Sub
Well basically, it will just copy the text contents of the text file to your document. You can add additional functions to process the contents and format it.
No comments:
Post a Comment