` Printed Icetips Article

Icetips Article



Par2: Send report output to word
2001-11-23 -- Kevin Erskine
 
When report done call this procedure (in AskPreview, Priority 4000) ...

Word:SendReport        PROCEDURE(REPORT       p_Report      , |
                                                            PreviewQueue
p_PreviewQueue)
WordOle         LONG
PageCnt         LONG
PageNo          LONG
 CODE
!---
 ENDPAGE(p_Report)
!---
 PageCnt = RECORDS(p_PreviewQueue)
 IF PageCnt = 0
    RETURN
 END
!---
!! IF MESSAGE('Do you also want to write this report to a WORD
file?','Confirmation...', |
!!            ICON:Question,BUTTON:Yes+BUTTON:No,BUTTON:Yes)= BUTTON:No
!!    RETURN
!! END
!---
 WordOle = CREATE(0,CREATE:Ole)
 WordOle{PROP:Create} = 'Word.Document'  !'Word.Document.8'
 IF WordOle{PROP:Ole} = FALSE
    MESSAGE('Could not locate MS Word on your computer. Request
Cancelled!','Notification...', |
            ICON:Exclamation,BUTTON:Cancel)
    DESTROY(WordOle)
    RETURN
 END
!WordOle{PROP:ReportException       } = TRUE
!---
 WordOle{PROP:DoVerb                } = -3 ! DOVERB:Hide
 WordOle{'Application.Visible'      } = False
 WordOle{'Application.Documents.Add'}
!---
 IF p_Report{PROP:LandScape}
    WordOle{'Application.ActiveDocument.PageSetup.Orientation' } =  1
    WordOle{'Application.ActiveDocument.PageSetup.PageWidth'   } = 11.00
    WordOle{'Application.ActiveDocument.PageSetup.PageHeight'  } =  8.50
    !-
    WordOle{'Application.ActiveDocument.PageSetup.TopMargin'   } = 0.25
    WordOle{'Application.ActiveDocument.PageSetup.BottomMargin'} = 0.50
    WordOle{'Application.ActiveDocument.PageSetup.LeftMargin'  } = 0.25
    WordOle{'Application.ActiveDocument.PageSetup.RightMargin' } = 0.25
 ELSE
    WordOle{'Application.ActiveDocument.PageSetup.Orientation' } =  0
    WordOle{'Application.ActiveDocument.PageSetup.PageWidth'   } =  8.50
    WordOle{'Application.ActiveDocument.PageSetup.PageHeight'  } = 11.00
    !-
    WordOle{'Application.ActiveDocument.PageSetup.TopMargin'   } = 0.25
    WordOle{'Application.ActiveDocument.PageSetup.BottomMargin'} = 0.50
    WordOle{'Application.ActiveDocument.PageSetup.LeftMargin'  } = 0.25
    WordOle{'Application.ActiveDocument.PageSetup.RightMargin' } = 0.25
 END
!---
 LOOP PageNo = 1 TO PageCnt
   GET(p_PreviewQueue,PageNo)
   WordOle{'Application.Selection.InlineShapes.AddPicture ("'&
Clip(p_PreviewQueue.Filename) &'")'}
 END
!---
 WordOle{'Application.Visible'} = True
 WordOle{PROP:DeActivate      }
!---
 DESTROY(WordOle)
!---
 RETURN



Printed November 21, 2024, 7:25 am
This article has been viewed/printed 35286 times.