?
Solved

Exporting

Posted on 2003-02-26
6
Medium Priority
?
412 Views
Last Modified: 2013-12-18
This should be real easy or impossible!

I need to give the users of the db I'm working on the ability to locate several documents, then export them to Word.

I know I can do an export whilst in a document and export to Word. I know I can use the @command to do the job. What I don't know is how to do this from LotusScript, so I can export the selected documents in a view rather than the view.

Doable or impossible?
0
Comment
Question by:gbentley
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 63

Expert Comment

by:Zvonko
ID: 8031736

Doable :-)




Here a lately answered Q:
http://www.experts-exchange.com/Applications/Email/Lotus_Notes/Q_20443119.html

Tell me your Document fields and I can provide a short reduced version for your design basis.

So long,
Zvonko

0
 
LVL 5

Author Comment

by:gbentley
ID: 8031774
zvonko - Thanks for the quick response. I was really after getting the whole document as formatted (exactly what you get if you open the document and choose File/Export) as there are a number of richtext fields.

I've found some code on the Sandbox, so I'll see how that goes for the moment.
0
 
LVL 63

Accepted Solution

by:
Zvonko earned 225 total points
ID: 8031806
Hey, I have never tried before this document-to-Word function.
I am excited! :-)

All the time I was doing it the hard way by using COM/OLE.

If you need some help with the Sandbox examples let me know.

So long,
Zvonko

0
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!

 
LVL 5

Author Comment

by:gbentley
ID: 8031845
The sample I found also uses COM/OLE and the method is somewhat similar to yours, so don't get too excited!

I'll get back tomorrow with some news.
0
 
LVL 5

Author Comment

by:gbentley
ID: 8070205
zvonko - Her is the code I came up with on the weekend. It does a mail merge into Word using the fields on the documents in the view it is run from. The Export Template documents just have a name and a template.

I make no claims to this being at all sturdy or perfect, but it is doing what I wanted and as the final format of the export is controlled by the merge document, it satisfies my users.

Sub Initialize
      Dim workspace As New NotesUIWorkspace
      Dim session As New NotesSession
      Dim db As NotesDatabase
      Dim sourceView As NotesUIView
      Dim sourceDoc As NotesDocument
      Dim selectedDocs As NotesDocumentCollection
      
      Dim templateView As NotesView
      Dim templateDoc As NotesDocument
      Dim templateNames() As String
      Dim selectedTemplateNameV As Variant
      
      Dim wordDocs As Variant
      Dim wordDoc As Variant
      Dim wordObj As Variant
      Dim range As Variant
      Dim tableObj As Variant
      Dim object As Variant
      Dim rtitem As Variant
      
      Dim i As Integer
      Dim rowNum As Integer
      Dim tempString As String
      
      Set db =workspace.CurrentDatabase.Database
      
      
      Set templateView = db.GetView("Templates")
      If templateView.AllEntries.Count < 1 Then ' No Templates
            Msgbox "You need to create some Templates before you can use the Export facility!"
            Exit Sub
      Elseif templateView.AllEntries.Count = 1 Then ' One Template, no need to prompt
            Set templateDoc = templateView.GetNthDocument(1)
      Else ' Get list of template names from Templates view
            Redim templateNames(1 To templateView.AllEntries.Count)
            For i = 1 To templateView.AllEntries.Count
                  templateNames(i) = templateView.GetNthDocument(i).GetFirstItem("ExportTemplateName").Text
            Next
            ' Get users selection
            selectedTemplateNameV = workspace.Prompt( PROMPT_OKCANCELLIST, "Templates", _
            "Please select a template to use for your export.", _
            templateNames(1), _
            templateNames)
            If selectedTemplateNameV = "" Then ' Exit on Cancel or no selection
                  Exit Sub
            End If
            ' Select chosen Template to use for export
            Set templateDoc = templateView.GetDocumentByKey( selectedTemplateNameV, True)
      End If
      
      'Get documents selected in View
      Set selectedDocs = db.UnprocessedDocuments
      Set sourceDoc = selectedDocs.GetFirstDocument
      If sourceDoc Is Nothing Then
            Exit Sub
      End If
      
      ' Create merge source doc and table
      Set wordObj = CreateObject("Word.Application.8")
      wordObj.visible = True
      Set wordDocs = wordObj.Documents
      wordDocs.Add
      Set wordDoc = wordObj.ActiveDocument
      Set range = wordDoc.Range(0,0)
      Set tableObj = wordObj.selection.Tables.Add(range,selectedDocs.Count+1,Ubound(sourceDoc.Items))
      ' Add column headings from field names
      For i = Lbound(sourceDoc.Items) To Ubound(sourceDoc.Items)
            tableObj.cell(1,i).select      
            wordObj.selection.typetext sourceDoc.Items(i).Name
      Next
      
      rowNum = 2
      'Process each document
      While Not(sourceDoc Is Nothing)
            ' Export documents fields to Word table
            For i = Lbound(sourceDoc.Items) To Ubound(sourceDoc.Items)
                  Call TableObj.cell(rowNum,i).select
                  tempString = sourceDoc.Items(i).Text
                  wordObj.selection.typetext tempString
            Next
            rowNum = rowNum + 1
            Set sourceDoc = selectedDocs.GetNextDocument(sourceDoc)
      Wend
      
      ' Save data file
      wordDoc.saveas "C:\temp\data.doc"
      wordDoc.close
      
      ' Get template from doc
      Set rtitem = templateDoc.GetFirstItem("ExportTemplateTemplate")
      
      ' Trap error on no attachment
      On Error Resume Next
      Forall o In rtitem.EmbeddedObjects
            If ( o.Type = 1453 ) Then
                  Set object = o
            End If
      End Forall
      On Error Goto 0
      
      ' Exit if no attachment
      If object Is Nothing Then
            Msgbox "That template has no attached file. Please attach a merge document and retry."
            wordObj.quit
            Exit Sub
      End If
      
      Set wordDoc = object.Activate(True)
      ' Perform merge to document
      wordDoc.MailMerge.MainDocumentType = wdFormLetters
      wordDoc.MailMerge.OpenDataSource "C:\temp\Data.doc"
      wordDoc.MailMerge.SuppressBlankLines = True
      wordDoc.MailMerge.Execute True
      Msgbox "Export Complete"
End Sub

Regards
Gordon
0
 
LVL 5

Author Comment

by:gbentley
ID: 9518330
zvonko - I gave you the points to close the question and because you gave me the link that got me started.

The code I posted (plus a few mods) has worked well for me. Feel free to use/abuse as you want.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

You’ve got a lotus Domino web server, and you have been told that “leverage browser caching” is a must do. This means that we have to tell the browser everywhere in the web to use cache. In other words, we set (and send) an expiration date in the HT…
Sometimes clients can lose connectivity with the Lotus Notes Domino Server, but there's not always an obvious answer as to why it happens.   Read this article to follow one of the first experiences I had with Lotus Notes on a client's machine, my…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

765 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