Juan,
I don't think you want to NewObject() the two things you are doing. I think Word.Document is for a OLE control on a VFP form. If you want to start Word and have it create a new document:
oWord = NewObject( "word.Application" )
oWordDoc = oWord.Documents.Add()
>My problem takes place when I instatiate Word97 in a Form.Method, validate the object as you requested and attempt to pass that object to functions in a procedure file:
>
>Does an OLE object lose its contents when passed around?
>
>Form.Method
>------------
>*-- let us assume that the below are valid objects
>oWord = NewObject("Word.Application")
>oWordDoc = NewObject("Word.Document")
>WordDocumentSetup( oWord, oWordDoc )
>
>*************************
>FUNCTION WordDocumentSetup( oWord, oWordDoc )
>*************************
>LOCAL m.llRetVal
>
>m.llRetVal = ( VARTYPE( oWordDoc.PageSetup ) == "O" .AND. !ISNULL( oWordDoc.PageSetup ) )
>
>IF !m.llRetVal
> =MessageBox( "oWordDoc.PageSetup does not evaluate to an object in WordDocumentSetup()", 0 + 16, "Invalid Object" )
> RETURN m.llRetVal
>ENDIF
>
>WITH oWordDoc.PageSetup
> .LineNumbering.Active = .F. && Program fails right here
> .Orientation = wdOrientPortrait
> .TopMargin = InchesToPoints(1)
> .BottomMargin = InchesToPoints(.50)
> .LeftMargin = InchesToPoints(1.00)
> .RightMargin = InchesToPoints(1.00)
> .Gutter = InchesToPoints(0)
> .HeaderDistance = InchesToPoints(.80)
> .FooterDistance = InchesToPoints(.50)
> .PageWidth = InchesToPoints(8.5)
> .PageHeight = InchesToPoints(11)
> .FirstPageTray = wdPrinterDefaultBin
> .OtherPagesTray = wdPrinterDefaultBin
> .SectionStart = wdSectionNewPage
> .OddAndEvenPagesHeaderFooter = .F.
> .DifferentFirstPageHeaderFooter = .T.
> .VerticalAlignment = wdAlignVerticalTop
> .SuppressEndnotes = .F.
> .MirrorMargins = .F.
> PUBLIC m.gnWorkArea
> m.gnWorkArea = .PageWidth - ( .LeftMargin + .RightMargin )
>ENDWITH
>
>RETURN( m.llRetVal )