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.
Some functions sending to Word through OLE
Some functions sending to Word through OLE
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
- Antonio Linares
- Site Admin
- Posts: 42529
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 77 times
- Contact:
Re: Some functions sending to Word through OLE
Michel,
For setting a font I just found this:
that could be this:
For setting a font I just found this:
Code: Select all | Expand
my $range = $doc->Range(0, length($text));
$range->Font->{Size} = 12;
$range->Font->{ColorIndex} = 5; #Magenta
that could be this:
Code: Select all | Expand
oRange = oDoc:Range( 0, nLen ) // desired length
oRange:Font:Size = 12
oRange:Font:ColorIndex = 5 // Magenta
- Antonio Linares
- Site Admin
- Posts: 42529
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 77 times
- Contact:
Re: Some functions sending to Word through OLE
I found this for replacing text: (to remove tabs you could replace them with an empty string (?))
http://msdn.microsoft.com/en-us/library/vstudio/f1f367bx.aspx?cs-save-lang=1&cs-lang=vb
http://msdn.microsoft.com/en-us/library/vstudio/f1f367bx.aspx?cs-save-lang=1&cs-lang=vb
Code: Select all | Expand
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
- Antonio Linares
- Site Admin
- Posts: 42529
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 31 times
- Been thanked: 77 times
- Contact:
- alerchster
- Posts: 97
- Joined: Mon Oct 22, 2012 4:43 pm
- Has thanked: 2 times
Re: Some functions sending to Word through OLE
Michel,
May be that helps
May be that helps
Code: Select all | Expand
#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
Regards
Ing. Anton Lerchster
Ing. Anton Lerchster
- Otto
- Posts: 6404
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 24 times
- Been thanked: 2 times
- Contact:
Re: Some functions sending to Word through OLE
Hallo Anton,
viele Grüße aus Sillian.
mfg
Otto
viele Grüße aus Sillian.
mfg
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
Re: Some functions sending to Word through OLE
Thank you all for your suggestions.
I'm going to try them out during the weekend.
To Antonio : with tabs I mean positions in a line where I want the cursor to jump to by pressing the TAB-key.
I'm going to try them out during the weekend.
To Antonio : with tabs I mean positions in a line where I want the cursor to jump to by pressing the TAB-key.
Regards,
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.09 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773