` Writing text to MS-Word document or template (Glenn Rathke) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

OLE/ActiveX: Writing text to MS-Word document or template
2004-04-16 -- Glenn Rathke
 
Newsgroups: comp.lang.clarion,softvelocity.clarion.third_party Actually it is not all that difficult opening and writing to a document. Here is the code I use to search and replace my own tokens in a word template: Use as you see fit. WordMagic Routine ! Save Document As ?Ole{PROP:ReportException} = TRUE !This is to report any OLE errors ?Ole{PROP:Create} ='Word.Application' !Run Word ?Ole{'Application.WindowState'} = 1 !To Maximize ?Ole{'Documents.Open("' & CLIP(LOC:FileName) & '")'} ?Ole{'Application.Visible'} = True ?Ole{'Application.Selection.Find.Forward'} = -1 ?Ole{'Application.Selection.Find.Wrap'} = 1 ?Ole{'Application.Selection.Find.Format'} = 0 ?Ole{'Application.Selection.Find.MatchCase'} = 0 ?Ole{'Application.Selection.Find.MatchWholeWord'} = 0 ?Ole{'Application.Selection.Find.MatchWildcards'} = 0 ?Ole{'Application.Selection.Find.MatchSoundsLike'} = 0 ?Ole{'Application.Selection.Find.MatchAllWordForms'} = 0 Counter# = 0 Loop 6 Times Counter# += 1 ?Ole{'Application.Selection.Find.ClearFormatting'} ?Ole{'Application.Selection.Find.Replacement.ClearFormatting'} Execute Counter# Begin ?Ole{'Application.Selection.Find.Text'} = '' ?Ole{'Application.Selection.Find.Replacement.Text'} = Format(Today(),@D18) End Begin ?Ole{'Application.Selection.Find.Text'} = '' ?Ole{'Application.Selection.Find.Replacement.Text'} = LOC:CurrentAddress End Begin ?Ole{'Application.Selection.Find.Text'} = '' ?Ole{'Application.Selection.Find.Replacement.Text'} = Peo:FirstName End Begin ?Ole{'Application.Selection.Find.Text'} = '' ?Ole{'Application.Selection.Find.Replacement.Text'} = Peo:LastName End Begin ?Ole{'Application.Selection.Find.Text'} = '' ?Ole{'Application.Selection.Find.Replacement.Text'} = CLIP(CLIP(Peo:FirstName) & ' ' & CLIP(Peo:LastName)) End Begin ?Ole{'Application.Selection.Find.Text'} = chr(10) ?Ole{'Application.Selection.Find.Replacement.Text'} = '' End End ?Ole{'Application.Selection.Find.Execute (,,,,,,,,,,2)'} End If LOC:SaveDocument = Button:Yes PeoD:DocName = GLO:Templates & PeoD:DocID PeoD:DocName = PeoD:DocName & '.DOC' Do GetFileName ! PeoD:Description PeoD:Description = PeoD:Description & ' DOC ' ?Ole{'ActiveDocument.SaveAs("' & CLIP(PeoD:DocName) & '",,,,0)'} ! Don't add to recent files Else PeoD:DocName = 'C:\CM.DOC' Remove(PeoD:DocName) ?Ole{'ActiveDocument.SaveAs("' & CLIP(PeoD:DocName) & '",,,,0)'} ! Don't add to recent files PeoD:DocName = 'Not Saved' Do GetFileName ! PeoD:Description PeoD:Description = PeoD:Description & ' DOC not saved ' ?EditDocument{Prop:Hide} = True Display() End


Today is November 21, 2024, 3:31 am
This article has been viewed 35414 times.
Google search has resulted in 643 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: