FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index All products support Word e il "layout di stampa"
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Word e il "layout di stampa"
Posted: Sun Jan 15, 2006 08:09 PM

Salve,
sto cercando di aprire un file rtf da Word via ole,
per questo nessun problema.
Vorrei però che il documento appaia visualizzato come "Layout di stampa" (vedi Visualizza/Layout di stampa) in microsoft word.

Qualcuno conosce il comando Ole per attivare la visualizzazione come "Layout di stampa" per il documento corrente ?

Grazie in anticipo

Marco Turco

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Word e il "layout di stampa"
Posted: Sun Jan 15, 2006 10:17 PM
Eccoti un esempio funzionante:

#define wdPrintView  3


FUNCTION MAIN()

    LOCAL oWord

    oWord = CreateObject( "Word.Application" )

    oWord:Documents:Add()

    oWord:ActiveDocument:ActiveWindow:View:Type = wdPrintView

    oWord:Visible = .T.

    RETURN NIL


EMG
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Word e il "layout di stampa"
Posted: Mon Jan 16, 2006 02:26 PM

Funziona, tuttavia mi appare in modo random il messaggio di errore


Application

Path and name: K:\pigc\PIGC.Exe (32 bits)
Size: 6,569,472 bytes
Time from start: 0 hours 0 mins 37 secs
Error occurred at: 16/01/06, 12:54:13
Error description: Error Word.Application:ACTIVEDOCUMENT/1 Unknown error: ACTIVEWINDOW
Args:

Stack Calls

Called from TOLEAUTO:ACTIVEWINDOW(0)


ed inoltre, dovendo richiamare la funzione più volte con difersi file rtf da aprire, non dovrei chiudere l'oggetto per non saturare la memoria ?
Vedi funzione Displayrtf in basso.

Marco

function DisplayRtf(cRtfFileName)

local oWord
local wsPrintView:=3

oWord := CreateObject("Word.Application")
oWord:Documents:Open(cRtfFileName)
oWord:ActiveDocument:ActiveWindow:View:Type = wsPrintView
oWord:Visible:=.t.

return nil

Best Regards,



Marco Turco

SOFTWARE XP LLP
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Word e il "layout di stampa"
Posted: Mon Jan 16, 2006 02:53 PM
Prova così:

#define wdPrintView  3


FUNCTION MAIN()

    LOCAL oWord

    TRY
        oWord = GETACTIVEOBJECT( "Word.Application" )
    CATCH
        oWord = CREATEOBJECT( "Word.Application" )
    END

    oWord:Documents:Add()

    oWord:ActiveDocument:ActiveWindow:View:Type = wdPrintView

    oWord:Visible = .T.

    RETURN NIL


EMG
Posts: 858
Joined: Fri Oct 07, 2005 12:00 PM
Word e il "layout di stampa"
Posted: Tue Jan 17, 2006 05:49 PM

Grazie. E' tutto Ok adesso.

Saluti

Marco

Best Regards,



Marco Turco

SOFTWARE XP LLP

Continue the discussion