` Comment on an Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Add a comment to an Icetips Article

Please add your comments to this article. Please note that you must provide both a name and a valid email address in order for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!

Your Name:  
Email:  
Header text/Subject:  

Please enter your comment in the box below:

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

OLE/ActiveX: MS-Word mail-merge macros
2004-07-02 -- Chris Rybitski
 
Newsgroups: softvelocity.clarion.language Arnor, FWIW, here is a VB example of using Word automation. It's a late-bound example, but the early-bound code is still there, just commented. HTH! '====================================================== Public Sub DoMailMerge(ByVal psMergeDoc As String, ByVal psNewDoc As String, ByVal psDataFile As String, ByVal pbAutoStart As Boolean, Optional ByVal pbSuppressBlankLines As Boolean = True) On Error Resume Next 'Early binding on MSWord is depreciated ' ' Dim loWordApp As Word.Application ' Dim loWordDoc As Word.Document ' Dim loMrgDoc As Word.Document Dim loWordApp As Object Dim loWordDoc As Object Dim loMrgDoc As Object 'Set loWordApp = New Word.Application Set loWordApp = CreateObject("Word.Application") Set loWordDoc = loWordApp.Documents.Open(psMergeDoc) With loWordDoc.MailMerge .MainDocumentType = 0 ' - ENUM WdMailMergeMainDocType.wdFormLetters .OpenDataSource psDataFile, 4 ' - ENUM WdOpenFormat.wdOpenFormatText '.SuppressBlankLines = True .SuppressBlankLines = pbSuppressBlankLines .Destination = 0 ' - ENUM WdMailMergeDestination.wdSendToNewDocument .Execute Pause:=False End With For Each loMrgDoc In loWordApp.Documents If loMrgDoc.Name = loWordDoc.Name Then loWordDoc.Close SaveChanges:=False Else loMrgDoc.SaveAs (psNewDoc) If pbAutoStart Then loMrgDoc.Close SaveChanges:=True End If End If Set loMrgDoc = Nothing Next Set loMrgDoc = Nothing Set loWordDoc = Nothing If pbAutoStart Then loWordApp.Visible = True loWordApp.Documents.Open psNewDoc Else loWordApp.Quit End If Set loWordApp = Nothing End Sub '======================================================


Today is November 21, 2024, 5:01 pm
This article has been viewed 35411 times.
Google search has resulted in 139 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: