Hello,
Can someone tell me how to send these commands to Word through OLE ?
- Setting a font
- Clearing all tabs
- Setting tabs (right and left)
Thank you very much in advance.
my $range = $doc->Range(0, length($text));
$range->Font->{Size} = 12;
$range->Font->{ColorIndex} = 5; #Magenta
oRange = oDoc:Range( 0, nLen ) // desired length
oRange:Font:Size = 12
oRange:Font:ColorIndex = 5 // Magenta
Private Sub SearchReplace()
Dim FindObject As Word.Find = Application.Selection.Find
With FindObject
.ClearFormatting()
.Text = "find me"
.Replacement.ClearFormatting()
.Replacement.Text = "Found"
.Execute(Replace:=Word.WdReplace.wdReplaceAll)
End With
End Sub
#Include "FiveWin.ch"
//--------------------------//
Function Main()
LOCAL oWord, oSelection, nX, nPoint := 60
oWord := CreateObject("Word.Application") //creating Wordobject
oWord:visible := .T.
oWord:Documents:Add() //adding a new document
oSelection := oWord:Selection //getting the active selection
With Object oSelection
:TypeText("Now setting the tabs"+CRLF)
WITH OBJECT :ParagraphFormat:TabStops
:ClearAll() //clearing all existing tabs
FOR nX := 1 TO 3
:Add( nPoint, 0) //adding new left tabs
nPoint += 60
NEXT
END WITH
:TypeText("left"+CHR(9)+"2"+CHR(9)+"3"+CRLF)
nPoint := 60
WITH OBJECT :ParagraphFormat:TabStops
:ClearAll() //clearing all existing tabs
FOR nX := 1 TO 3
:Add( nPoint, 1) //adding new center tabs
nPoint += 60
NEXT
END WITH
:TypeText("center"+CHR(9)+"22222"+CHR(9)+"3333"+CRLF)
nPoint := 60
WITH OBJECT :ParagraphFormat:TabStops
:ClearAll() //clearing all existing tabs
FOR nX := 1 TO 3
:Add( nPoint, 2) //adding new right tabs
nPoint += 60
NEXT
END WITH
:TypeText("right"+CHR(9)+"2"+CHR(9)+"3"+CRLF)
nPoint := 60
WITH OBJECT :ParagraphFormat:TabStops
:ClearAll() //clearing all existing tabs
FOR nX := 1 TO 3
:Add( nPoint, 3) //adding new decimal tabs
nPoint += 60
NEXT
END WITH
:TypeText("decimal"+CHR(9)+"2,1"+CHR(9)+"3,1"+CRLF+CRLF)
:TypeText("Now setting fonts"+CRLF)
WITH OBJECT :ParagraphFormat:TabStops
:ClearAll() //clearing all existing tabs
END WITH
:Font:Name="Arial"
:TypeText("Arial"+CHR(9)+"2"+CHR(9)+"3"+CRLF)
:Font:Size=16
:TypeText("Arial Size 16"+CHR(9)+"2"+CHR(9)+"3"+CRLF)
:Font:Size=10
:Font:Name="Courier"
:TypeText("Courier Size 10"+CHR(9)+"2"+CHR(9)+"3"+CRLF)
:Font:Bold=1
:TypeText("Courier Bold 10"+CHR(9)+"2"+CHR(9)+"3"+CRLF)
:Font:Bold=0
:TypeText("Courier Normal 10"+CHR(9)+"2"+CHR(9)+"3"+CRLF)
:Font:Italic=1
:TypeText("Courier Italic 10"+CHR(9)+"2"+CHR(9)+"3"+CRLF)
:Font:Italic=0
:TypeText("Courier Normal 10"+CHR(9)+"2"+CHR(9)+"3"+CRLF)
end with
Return nil
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: Google [Bot] and 103 guests