Solved

Export Notes Documents to Word

Posted on 2000-05-05
2
468 Views
Last Modified: 2013-12-18
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
Comment
Question by:giusepe
  • 2
2 Comments
 
LVL 4

Accepted Solution

by:
stamp earned 20 total points
ID: 2900915
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
 
LVL 4

Expert Comment

by:stamp
ID: 2901028
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
Article by: Rob
Notes 8.5 Archiving Steps and Tips This article covers setting up a Notes archive, and helps understand some of the menu choices making setting up and maintaining a Notes archive file easier.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

759 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now