Un ejemplo de exportacion sacado de los foros del notesring
Hola a todos,
Tengo que crear un documento word a partir de un documento notes, volcando los datos de éste ulltimo. Hasta ahora he conseguido generar el documento word y volcar datos de tipo texto. Lo que no he conseguido es volcar una imagen abierta a ese mismo doc word; esta imagen la he guardado abierta también en Notes, en un campo de texto enriquecido. No sé que sentencia debo usar, parte del código es:
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim count As Integer
Dim r As Integer
Dim header As String
Dim rows As Integer
Dim wks As New NotesUIworkspace
Dim View As NotesUIView
Set View = wks.currentview
Dim vista As NotesView
Dim vc As NotesViewEntryCollection
Dim entry As NotesViewEntry
'These are Word constants
Const wdAlignParagraphLeft = 0
Const wdAlignParagraphCenter = 1
Const wdAlignParagraphRight = 2
Set db = session.CurrentDatabase
'Set collection = db.AllDocuments
Set View = wks.currentview
Set vista = View.view
Set vc = vista.AllEntries
'count = collection.Count
count=vc.Count
If count = 0 Then
Messagebox "No Documents exist on this view to Export!!"
Exit Sub
End If
'Add one item to the count for the table column headings
rows = count + 1
'The selected Word template is opened from to the user's harddisk.
'Using this template a new Word document is created.
'This document is filled with the correct information, and then saved on the user's harddisk. A table is built within the Word document.
Print"Starting Word, please wait..."
Set WordApp = CreateObject("Word.Application")
WordApp.Visible = True
'Opening the template as a new doc
WordApp.Documents.Add("C:\lotus\notes\data\Plantillauniones.doc")
'Create a Word document, and get a handle to it
''''Call wordAppObject.Documents.Add
Set wordDocObject = WordApp.ActiveDocument
'Move the cursor in the Word template where the table will be built
' WordApp.ActiveDocument.Bookmarks("Begin").Select
'Add a table with doc count number of rows and 9 columns
wordDocObject.Paragraphs.Add
Set wordParagraphObject = wordDocObject.Paragraphs(1)
With wordParagraphObject
.Range.Font.Size = 8
.Range.Font.Bold = False
.SpaceAfter = 6
End With
Set wordRangeObject = wordParagraphObject.Range
Set wordTableObject = _
wordDocObject.Tables.Add(wordRangeObject, rows, 9)
'Begin HEADERS formatting here
r=1 'set the cursor to the first row of the table
'Add header to the first cell of the table
Set wordCellObject = wordDocObject.Tables(1).Cell(r,1)
wordCellObject.Column.Width = 50
Set wordParagraphObject = _
wordDocObject.Paragraphs.Add(wordCellObject.Range)
Print "Inserting Issue Number..."
With wordParagraphObject
.Range.Font.Size = 8
.Range.Font.Bold = True
.Range.Text = "Nº Encargo."
.Alignment = wdAlignParagraphCenter
End With
.............
r=1 'set the first row for the addition of entry documents after the headings
For i = 1 To count
r = r+1 'add 1 to row count
'Set doc = collection.GetNthDocument(i)
Set entry = vc.GetNthEntry(i)
Set doc = entry.Document
Msgbox doc.~_encargo(0) + doc.~_nombencargo(0)
'Filling the Word document
'Add data to the first cell of the table
Set wordCellObject = wordDocObject.Tables(1).Cell(r,1)
wordCellObject.Column.Width = 50
Set wordParagraphObject = _
wordDocObject.Paragraphs.Add(wordCellObject.Range)
Print "Inserting Issue Number..."
With wordParagraphObject
.Range.Font.Size = 8
.Range.Font.Bold = False
.Range.Text = doc.~_nencargo(0)
.Alignment = wdAlignParagraphCenter
End With
.....
Next i
WordApp.Activedocument.PrintOut
Set wordAppObject = Nothing
Set wordDocObject = Nothing
Print "Closing Word..."
WordApp.Application.Quit
Print "Closed..."
Set WordApp = Nothing
Print ""
Messagebox "The Word Document was created successfully, Click OK"
Print "Export completed successfully"
Tampoco consigo que me guarde la imagen abierta, me la pone como anexo, y le digo que me lo inserte como objeto: si es un doc de Word sí que lo guarda abierto, sino no...
Muchas gracias por todo
|
Otros documentos de LotusScript
|