Public Word_ As Word.Application
'Objeto Word
Sub AgregarWord(Texto_A_Escribir As String, Nombre_ArchivoTXT As String)
If Nombre_ArchivoTXT = "" Then Exit Sub
Dim Texto As String
Dim Nombre_Archivo As String 'este es el nombre del archivo sin la extensión.
Texto = Texto_A_Escribir
Dim Doc As Word.Document
'Iniciar word
Set Word_ = New Word.Application
Word_.Visible = True
'Iniciar documento
Set Doc = Word_.Documents.Add
Doc.Activate
'AGREGA TEXTO
Word_.Selection.Font.Color = wdColorBlack
Word_.Selection.Font.Name = "Courier new"
Word_.Selection.TypeText Texto
'AGREGA PARRAFO
Word_.Selection.TypeParagraph
'Quitando seleccion
Word_.Selection.EndOf
'SELECCIONA TEXTO
On Error GoTo Adelante
Word.Selection.WholeStory
Word.Selection.Font.Size = 10
Word_.Selection.EndOf
Adelante1:
Nombre_Archivo = Left(Nombre_ArchivoTXT, Len(Nombre_ArchivoTXT) - 4)
Doc.SaveAs App.Path & "" & Nombre_Archivo & ".doc"
Word_.Quit True
Set Word_ = Nothing
Adelante:
If Err.Number = 462 Then
Resume Adelante1
End If
End Sub
Public Function LeerTexto(ArchivoTXT As String) As String
If ArchivoTXT = "" Then Exit Function
Dim NroLibre As Integer
Dim Ruta As String
Dim Linea As String
Dim Texto As String
Ruta = App.Path & "" & ArchivoTXT
NroLibre = FreeFile
Open Ruta For Input As #NroLibre
While Not EOF(1)
Line Input #NroLibre, Linea
Texto = Texto & Linea & vbCrLf
Wend
Close #NroLibre
LeerTexto = Texto
End Function