Some functions sending to Word through OLE

Some functions sending to Word through OLE

Postby driessen » Mon May 27, 2013 1:02 pm

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.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Some functions sending to Word through OLE

Postby Antonio Linares » Mon May 27, 2013 3:13 pm

Michel,

For setting a font I just found this:
Code: Select all  Expand view
my $range = $doc->Range(0, length($text));
$range->Font->{Size} = 12;
$range->Font->{ColorIndex} = 5; #Magenta


that could be this:
Code: Select all  Expand view

oRange = oDoc:Range( 0, nLen ) // desired length
oRange:Font:Size = 12
oRange:Font:ColorIndex = 5 // Magenta
 
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42093
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Some functions sending to Word through OLE

Postby Antonio Linares » Mon May 27, 2013 3:23 pm

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

Code: Select all  Expand view
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
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42093
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Some functions sending to Word through OLE

Postby Antonio Linares » Mon May 27, 2013 3:25 pm

Maybe tabs meant a different thing ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42093
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Some functions sending to Word through OLE

Postby alerchster » Mon May 27, 2013 4:51 pm

Michel,

May be that helps

Code: Select all  Expand view
#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
User avatar
alerchster
 
Posts: 93
Joined: Mon Oct 22, 2012 4:43 pm

Re: Some functions sending to Word through OLE

Postby Otto » Mon May 27, 2013 7:23 pm

Hallo Anton,
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
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Some functions sending to Word through OLE

Postby driessen » Wed May 29, 2013 8:35 am

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.
Regards,

Michel D.
Genk (Belgium)
_____________________________________________________________________________________________
I use : FiveWin for (x)Harbour v. 24.07 - Harbour 3.2.0 (February 2024) - xHarbour Builder (January 2020) - Bcc773
User avatar
driessen
 
Posts: 1422
Joined: Mon Oct 10, 2005 11:26 am
Location: Genk, Belgium

Re: Some functions sending to Word through OLE

Postby byte-one » Wed May 29, 2013 10:03 am

Oh, noch ein Kärntner! :)
Regards,
Günther
---------------------------------
office@byte-one.com
User avatar
byte-one
 
Posts: 1048
Joined: Mon Oct 24, 2005 9:54 am
Location: Austria


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], nageswaragunupudi and 115 guests