[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 496
  • Last Modified:

Export Notes Documents to Word

I need to export documents contained in views to Word, according to LotusScript this is possible with OLE. I need the CODE to do this or where can i find sample CODE to Export TO WORD. URGENT.

To have an idea of the documents and the database i am working on, this is for more detail:

I am working in a database in Lotus Notes and i need to create a document in Word with the information contained in different views of the database.
The structure of the documents in the database are: there are documents type Document, Response and Response to Response. What i need is create a document in Word where i can obtain the informaion in that Notes database.
Is it possible to create such document in such a manner that when the datbase in updated, the docuemnt is updated also?
I have been trying exporting the views to an ascii file and then open that file in Word, but such document can not be updated automatically. Also i have used an ODBC to catch the information, but because of the structure in the types of documents ( response, response to response ) the tables in Access are separated and can not obtain the information of the documents properly.

Is there any way that you know where i can create a Word document with the information contained in the Notes Database (Views )and make that document updated when the database changes or maybe create an agent to do this?

DATABASE
    VIEWS
        DOCUMENTS ( Document, Response,   Response to Response )    
            .......
            .......
            .......
            .......
            .......
             ....
              ..
              ..
       Word Document ( Updated )
 
I will be very thankfull with all the ideas that you can provide me to solve this.
Thanks.
0
giusepe
Asked:
giusepe
  • 2
1 Solution
 
stampCommented:
Hi giusepe,

this is a tested copy from here:
http://www.martinscott.com/Site/DesignLibrary.nsf/f7cf0bf6ffdb8cec852566c1005348b2/a772d7a19cc467ee85256739003a073e?OpenDocument

And here how I did it...

Create in your view an action, name it "ExportToWord97"
Place into "Click" event this code:
Sub Click(Source As Button)
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim collection As NotesDocumentCollection
      Dim doc As NotesDocument
      Dim idpath As String
      Dim rtitem As NotesRichTextItem
      Dim object As NotesEmbeddedObject
      Dim wordobj As Variant
      Dim add As String
      Dim sal As String
      Dim LastName As String
      Dim FullName As String
    ' this code uses many of the Wordbasic commands in Word 97
    'set up the word document
      
      Set wordobj = CreateObject("Word.Basic.8")
      If WordObj Is Nothing Then
            Msgbox "There was a problem loading MS Word."
            Exit Sub
      End If
      
      Set db = session.CurrentDatabase
      Set collection = db.UnprocessedDocuments
      For i = 1 To collection.Count
            Set doc = collection.GetNthDocument( i )
            Call session.UpdateProcessedDoc( doc )
    'get the Address, Salutation , lastname and fullname fields    from    the current document
            
            add=doc.MailAddress(0 )
            sal=doc.Salutation(0)
            LastName=doc.LastName(0)
            FullName=doc.FullName(0)
            
    ' create new doc in MS Word
            WordObj.filenew  
            wordobj.font "Univers"
            wordobj.fontsize 11
            
            wordobj.insertpara
            wordobj.insertpara
            wordobj.insertpara
            wordobj.insertpara
            wordobj.insertpara
            
    ' time format i.e 5 Febuary, 1999
            DateTimeFormat="d MMMM, yyyy"
            
    ' inset the text and the field values
            wordobj.insert "Our Ref:"
            wordobj.insertpara
            wordobj.insert "Your Ref:"
            wordobj.insertpara
            wordobj.insert "IPC:"
            wordobj.insertpara
            wordobj.insertpara
            wordobj.insertpara
            
            
            wordobj.insert "Date:"
            
            wordobj.InsertDateTime    DateTimeFormat
            wordobj.insertpara
            wordobj.insertpara
            wordobj.insertpara
            wordobj.underline
            wordobj.insert "For the attention of : "
            wordobj.insert Fullname
            wordobj.underline
            wordobj.insertpara
            wordobj.insertpara
            
            wordobj.insert add
            wordobj.insertpara
            wordobj.insertpara
            wordobj.insertpara
            
            wordobj.insert "Dear  " & Sal &  "  " & Lastname
            wordobj.insertpara
            wordobj.insertpara
            
            wordobj.insert "Subject:"
            wordobj.insertpara
            wordobj.insertpara
            
            
      WordObj.fileSaveAs "myNew" & i & ".doc"
            
      Next
      
      
End Sub


Now go to the client, select some of your docs and click on the  "ExportToWord97" action button.

So, this was for 20 Points. What you have to do is testing with abowe code (I hope you have Word97). Check for some variables contained in your docs to transfer to WordDocs. When you have enough tested, then you can forget this and do it with OLE objects. But for this I do not have a immediate example...


So long,
stamp
0
 
stampCommented:
I forgot...

place after:
WordObj.fileSaveAs "myNew" & i & ".doc"

this statement:
wordObj.fileClose

and after the "next" loop end close word with this:
Set WordObj = Nothing

So, now your question how to update docs in a folder; well, you have to have any criteria in your notesdocs what the name of worddoc should be.
The abowe action owerwrites yhe previous word.docs at next run time.
So you get your update. If you want to have it running electricaly, place the code to an agent, click on shareble box, give it selection: "If documents have been created or modified" and look at it...

Regards,
stamp
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now