Ayuda Urgente de nuevo Ernesto De Spirito
Publicado por Daniel (12 intervenciones) el 30/05/2003 00:45:01
Mi problema es la automatizacion de Office con Delphi. Por ahora me interesa Word. Tengo un documento que detalla el manejo de la automatizacion tanto de word como de Excel pero en Visual Basic. A continuación están algunos de los fragmentos de codigo en Visual Basic que no puedo traducirlos a Delphi.
Looping Through a Range of Paragraphs
There are two main ways of doing this:
Using the For Each .. Next Statement
This example loops through the first 5 paragraphs in the active document, adding text before each of them:
Set myDoc = ActiveDocument
Set myRange = myDoc.Range(Start:=myDoc.Paragraphs(1).Range.Start, _
End:=myDoc.Paragraphs(5).Range.End)
For Each para in myRange.Paragraphs
Para.Range.InsertBefore "Question: " & vbTab
Next para
Returning or Setting the Text in a Range
Use the Text property to return or set the contents of a Range object. This returns the first word in the active document:
strText = ActiveDocument.Words(1).Text
This changes the first word in the active document to "Hello"
ActiveDocument.Words(1).Text = "Hello"
Formatting the Text in a Range
Use the Font property to get character -formatting properties and methods, and the ParagraphFormat property to get to paragraph-formatting properties and methods. For example:
With ActiveDocument.Paragraphs(1).Range.Font
.Name = "Times New Roman"
.Size = 14
.AllCaps = True
End With
With ActiveDocument.Paragraphs(1).Range.ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.Space1
End With
En este tema, ¿Cómo debo manejarme?. Sé que la automatizacion tiene que ver con Interfaces COM pero ¿
Looping Through a Range of Paragraphs
There are two main ways of doing this:
Using the For Each .. Next Statement
This example loops through the first 5 paragraphs in the active document, adding text before each of them:
Set myDoc = ActiveDocument
Set myRange = myDoc.Range(Start:=myDoc.Paragraphs(1).Range.Start, _
End:=myDoc.Paragraphs(5).Range.End)
For Each para in myRange.Paragraphs
Para.Range.InsertBefore "Question: " & vbTab
Next para
Returning or Setting the Text in a Range
Use the Text property to return or set the contents of a Range object. This returns the first word in the active document:
strText = ActiveDocument.Words(1).Text
This changes the first word in the active document to "Hello"
ActiveDocument.Words(1).Text = "Hello"
Formatting the Text in a Range
Use the Font property to get character -formatting properties and methods, and the ParagraphFormat property to get to paragraph-formatting properties and methods. For example:
With ActiveDocument.Paragraphs(1).Range.Font
.Name = "Times New Roman"
.Size = 14
.AllCaps = True
End With
With ActiveDocument.Paragraphs(1).Range.ParagraphFormat
.LeftIndent = InchesToPoints(0.5)
.Space1
End With
En este tema, ¿Cómo debo manejarme?. Sé que la automatizacion tiene que ver con Interfaces COM pero ¿
Valora esta pregunta


0