Try its... (not free bug code...)
FUNCTION MyFunc
lParameters toWord,;
tcOutputDestination, ;
tiSepTray, ;
tcSepType, ;
tcSection
On Error DO SeparatorError WITH ERROR(),MESSAGE()
=DoEvents()
toWord.Documents.Add() &&Always put () for methods...
--------------
NOTE: Words Const is not accesible by VFP. You need a somenthing like word.h file (find it in files section), or replace wd* const with number values (see this in VB)
--------------
With toWord.ActiveDocument.PageSetup
.FirstPageTray = tiSepTray
.OtherPagesTray = tiSepTray
.VerticalAlignment = wdAlignVerticalCenter
EndWith
With toWord.Selection
If tcSepType = "P" Then
.InsertBreak Type:=wdPageBreak
.InsertBreak Type:=wdPageBreak
EndIf
If (tcSection <> "") Then
.ParagraphFormat.Alignment = wdAlignParagraphCenter
.Font.Bold = wdToggle
.Font.Size = 18
.TypeText('Text')=ConvertSepType(tcSection)
.TypeParagraph
EndIf
EndWith
=DoEvents()
DO Case
Case tcOutputDestination= "Printer"
toWord.PrintOut
Case tcOutputDestination= "Preview"
toWord.PrintPreview = True
=MESSAGEBOX("Separator Print Preview Ready")
EndCase
toWord.ActiveDocument.Close(wdDoNotSaveChanges)
=DoEvents()
RETURN
END FUNCTION
FUNCTION SeparatorError
lParametres errNumber,errDescrip
=MessageBox("Error:" + STR(ErrNumber)+CHR(13)+;
"In: PrintSeparator" +CHR(13)+;
"Description: " + ErrDescrip
END FUNCTION
The Life is Beautiful!
Programmer in
Delphi, VS.NET
MCP