
10/12/2004, 05:16
|
| | Fecha de Ingreso: diciembre-2004 Ubicación: Gran Canaria, España
Mensajes: 3
Antigüedad: 20 años, 2 meses Puntos: 0 | |
Hola, has probado la funcion CreateObject? /anders
Option Base 1
Public varText()
Sub AbrirWordDesdeExcel()
Dim strWordArchivo As Variant
Dim i, r, intLineas As Integer
Dim appWord As Word.Application
Dim appDoc As Word.Document
Dim rngDoc As Word.Range
'dialogo 'abrir archivo'
strWordArchivo = Application.GetOpenFilename ("Documentos Word (*.doc), *.doc"): On Error GoTo 99
'crear objeto Word
Set appWord = CreateObject("Word.Application")
Set appDoc = appWord.Documents.Open(strWordArchivo)
'leer Word
intLineas = appDoc.Paragraphs.Count: ReDim varText(intLineas)
r = 1
For i = 1 To intLineas
Set rngDoc = appDoc.Range( _
Start:=appDoc.Paragraphs(i).Range.Start, _
End:=appDoc.Paragraphs(i).Range.End)
varText(i) = rngDoc.Text
r = r + 1
Next i
'traspasar datos...
For x = 1 To UBound(varText)
Cells(x, 1) = varText(x)
Next x
appDoc.Close: Set appDoc = Nothing
appWord.Quit: Set appWord = Nothing
99:
End Sub |