Hi, we need to write a codes to convert all Notes document to a word (.rtf) format, so the codes will loop all documents in a notes view and each notes document will be converted to their associated Word document includes images etc.Please let me know if you have any good codes to achieve this. thanks a lot in advance.
Subject: Integra4Notes
If you’re going to do much of this at all, you may want to look at third party tools. We use Integra4Notes to migrate date from Notes to Word and Excel and the tool works great.
I have no relationship with Integra other than as a happy customer.
Doug
Subject: RE: Integra4Notes
Instead of buying a 3rd party tool, we prefer to code it ourself, I am wondering this is a common request, there should be a solution.The codes Mark provided works fine except the images, if we can convert the images to Word, then that would be perfect solution. Please let me know if anybody has any resource , idea or examples to achieve it. thanks a lot
Subject: RE: Integra4Notes
Instead of buying a 3rd party tool, we prefer to code it ourself
Then write the code yourself. You don’t want to buy any third-party tools, do you expect others to do all your work for you for free? You want to write the code, go ahead and do it. Nothing is preventing you.
I see a couple of options:
-
Hire an experienced Notes developer who knows what he/she is doing. This will cost you a little bit of money, but you will probably have something working in a day or less.
-
Use your existing Notes developer (I assume that is you), and spend a week or more to get something working.
Let’s say it takes the experienced developer eight hours to write the exporter, at $125/hour. That is $1,000.
Compare that with a less experienced developer, spending at least 40 hours, at the much lower rate $35/hour. That is $1,400.
Your company will be paying $400 more, and probably get an application without good error handling, etc.
A 3rd party tool might not cost more than that either.
Subject: Karl, Karl, Karl…sigh…
You are confusing real money with developer time. If a dev works for the company, then their time is factored into routine operations. Whether they spend the day doing productive stuff like building value added apps and improving exising apps or they spend it doing grunt work that could easily be managed by a third party tool, the money paid by the company is the same. The company will assume that any time the dev wastes re-inventing a wheel will be made up later by working longer hours or weekends.
If, on the other hand, somebody needs to actually write a check for something, even if that something makes a project better/faster/easier and decreases the effort to maintain or change the app over time, then that’s NEW money that has to be spent and if I know anything about anything, getting an exec to write a check is the equivelent of asking them to dip their hands in H2SO4…it burns, IT BURRRRNNNNNSSSS, DEAR LORD MAKE IT STOP!!!
I’m very lucky to work for a company that is, every once in a while, willing to get out the pen and write a check for a couple of grand.
So, while I totally agree that this is a perfect case for using a 3rd party tool, I can understand why that may not be possible. In this case, Peter is just going to have to slog through the pain of building something that kinda-sorta works based on the limited information available for the task. I wish him well and am glad I’m not him…
Subject: You are of course correct…
I guess I am lucky enough to have a boss who (while not having unlimited funds) is willing to spend money on 3rd party solutions and tools when needed.
Since I am busy with different development projects, as well as support of our users, we don’t have the luxury of having me spend a few weeks reinventing the wheel. That would delay other projects, and we would have a line of Vice Presidents, CIO/CFO/CEO type people at out door yelling for results. ![]()
So my boss can motivate the expense that way, since I don’t have any spare time for those kind of development tasks.
Another OT coment: Last year I moved in with my girlfriend. I moved from a 3 bedroom apartment (yes, I am nerdy enough to use one bedroom as home office/computer/server room) where I have been living for almost 10 years. So I had a lot of stuff.
She and I are working on a Domino based program, and she said my time was more valuable spent writing code than packing and moving, she simply (in her words) “threw money at the problem” and hired packers/movers. I spent some time sorting and throwing away things (I dumped about 10 old PCs and cases, 4-5 printers, etc), then I could focus on development instead of moving.
Sometimes the best and fastest solution is to throw some money at it. I just wished Peter’s employer would realize that.
Subject: RE: You are of course correct…
I am a programmer using vb.net language to develop my document image sdk. Recently, I encountered a pdf and word document processing and converting lirbary, which I refer to develop my own document converting tools. It contains the basic document rendering and converting plugins, including pdf to Word document and word to pdf document converting.
Subject: RE: Integra4Notes
I just tried the code and also ran into the image problem.
If you want to code it yourself, get out the search tool and just start poking around. Excel is easy because it’s data converted to data. Word is harder.
One other thing you may want to consider; if you have apps where multiple docs are treated as one data set (parent/child or in our case sets of docs related by category) the Word/PDF conversion creates one Word/PDF doc for each Notes doc. Integra allows you to concatenate multiple Notes docs into a single Word doc. I4N also has a complete development packet so you can, in fact, write your own custom code for special cases. We opted to let Integra write the code for us and are quite happy with the outcome.
I understand the third party thing; we tend not to buy stuff but we own Integra and TeamStudio Configurator; they pay for themselves the first time you use them.
Subject: RE: Integra4Notes
For us, it is simple case, there are no responses document or multiple documents convert to one word etc. We only convert each Notes document to one word document, not complicated.
In other word, each notes document will be converted their associated word document in local C:, of cause, the image(s) will be migrated with other contents.
MS Excel is converted well with Mark’s codes.
We are not allowed to user 3rd party tool, as I said, this is a common request, there should be a solution from the internet. I appreciate if anybody can help, thanks a lot,
Subject: Choices
I have used Swing Software in the past and it works great Lotus Notes Export to PDF: Converter for Notes - SWING Software
Try a search on google for “lotusscript java pdf creator open source” There are opensource java libraries that you can call (this is basically what Swing does but has a great wrapper to make it all nice and easy)
Subject: RE: Choices
Hi Barry, thanks for your info,
But, we want to convert notes document to word (rtf) format, NOT pdf.
Subject: ‘The Internet’
this is a common request, there should be a solution from the internet
Great concept but not always true. Some things are just hard to do and ‘the internet’ isn’t going to be much help. This is why 3rd party tools exist; there are people who see an opportunity to solve a problem IBM didn’t and ‘the internet’ hasn’t.
When you get something working, be sure to post the results so ‘the interet’ WILL have a solution. As a long time membe of these forums, I can’t tell you how many times someone asks for help then posts ‘figured out how to do it’ and then not post the code…if you know something, share!
Best of luck.
Subject: How to Migrate(convert) notes document to Word?
Try this…
you will have to modify it for your needs and likely skip the pdf step but should do the trick.
Cheers!
Subject: RE: How to Migrate(convert) notes document to Word?
Hi Mark, thanks for your quick response, unfortunately, the URL can not be opened, probably it is blocked, do you have any other resource?
Subject: RE: How to Migrate(convert) notes document to Word?
Here is the code…
%REM
Library PdfConverter
Created 11.07.2013 by Harald Reisinger
Description: Functions to generate RTF and PDF Documents from NotesDocuments
Needs the OpenLog Databse for Logging Errors (http://www.openntf.org/internal/home.nsf/project.xsp?action=openDocument&name=OpenLog)
%END REM
Option Public
Option Declare
Use “OpenLogFunctions”
Const APIModule = “NNOTES”
Const wdExportFormatPDF = 17
Const wdExportFormatXPS = 18
Const wdExportOptimizeForOnScreen = 1
Const wdExportOptimizeForPrint = 0
Const wdExportAllDocument = 0
Const wdExportCurrentPage = 2
Const wdExportFromTo = 3
Const wdExportSelection = 1
Const wdExportDocumentContent = 0
Const wdExportDocumentWithMarkup = 7
Const wdExportCreateHeadingBookmarks = 1
Const wdExportCreateNoBookmarks = 0
Const wdExportCreateWordBookmarks = 2
Declare Function MailGetMessageBodyComposite Lib APIModule Alias “MailGetMessageBodyComposite” ( ByVal hNT As Long, ByVal N As String, ByVal D As String, nD As Long) As Integer
Declare Function ExportRTF Lib “nxrtf” Alias “ExportRTF” (ByVal sTempFile As String, ByVal flags As Long, hmod As Long, ByVal altlibrary As String, ByVal sRTFFile As String) As Integer
%REM
Sub ConvertDocToRtfFile
Description: Converts a NotesDocument to an RTF-Document and saves it under the filePath
Generates and removes some temporary Files while Working
%END REM
Public Sub ConvertDocToRtfFile(doc As NotesDocument, filePath As String)
Dim tempDoc As NotesDocument
Dim tempRti As NotesRichTextItem
On Error GoTo ErrorHandler
Set tempDoc = doc.ParentDatabase.CreateDocument()
Set tempRti = tempDoc.CreateRichTextItem("Body")
Call doc.RenderToRTItem(tempRti)
Call ConvertItemToRtfFile(tempRti, filePath)
Exit Sub
ErrorHandler:
Call LogErrorEx("Error in: ConvertDocToRtfFile", SEVERITY_HIGH, doc)
Error Err, Error$
End Sub
%REM
Sub ConvertDocumentToPdf
Description: Converts a NotesDocument to an PDF-Document and saves it under the filePath
Needs an COM-Instace of a Word Application created with:
Dim word As Variant
Set word = CreateObject("Word.Application")
Generates and removes some temporary Files while Working
%END REM
Public Sub ConvertDocumentToPdf(doc As NotesDocument, word As Variant, filePath As String)
Dim wordDoc As Variant
On Error GoTo ErrorHandler
Call ConvertDocToRtfFile(doc, filePath & ".rtf")
'http://msdn.microsoft.com/en-us/library/office/bb216319(v=office.12).aspx
Set wordDoc = word.Documents.Open(filePath & ".rtf", False, True, False)
'http://msdn.microsoft.com/en-us/library/office/bb256835(v=office.12).aspx
Call wordDoc.ExportAsFixedFormat(filePath, wdExportFormatPDF, False, wdExportOptimizeForPrint, wdExportAllDocument, 0, 9999999, wdExportDocumentContent, True, True, wdExportCreateHeadingBookmarks, True, True, True, Nothing)
Call wordDoc.Close(0)
Kill filePath & ".rtf"
Exit Sub
ErrorHandler:
Call LogErrorEx("Error in: ConvertDocumentToPdf", SEVERITY_HIGH, doc)
Error Err, Error$
End Sub
%REM
Function ConvertItemToRtfFile
Description: Converts an NotesRichTextItem to an RTF-Document and saves it under the filePath
Generates and removes a temporary File while Working
%END REM
Public Sub ConvertItemToRtfFile(item As NotesRichTextItem, filePath As String)
On Error GoTo ErrorHandler
Dim fileSize As Long
Dim doc As NotesDocument
Set doc = item.Parent
Call MailGetMessageBodyComposite(doc.handle , "Body", filePath & ".cd", fileSize)
Call ExportRTF(filePath & ".cd", 0, 0, "", filePath)
Kill filePath & ".cd"
Exit Sub
ErrorHandler:
Call LogErrorEx("Error in: ConvertItemToRtfFile", SEVERITY_MEDIUM, doc)
Error Err, Error$
End Sub
Subject: RE: How to Migrate(convert) notes document to Word?
Hi Mark, Thanks a lot for your response again, I tried to use your codes as follow, basically, I created a view action button with this code and combined with your codes:Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim doc As NotesDocument
Dim filePath As String
Set db = session.CurrentDatabase
filePath = db.FilePath
Set collection = db.UnprocessedDocuments
Set doc = collection.GetFirstDocument()
While Not(doc Is Nothing)
Call ConvertDocToRtfFile(doc,filePath)
Set doc = collection.GetNextDocument(doc)
Wend
End Sub
… the rest codes are copied from your codes in my sub of this button, from my codes above, you can see basically, I want to codes execute after selected some notes document in view view, and then click this button to convert(migrate) those selected notes documents to word (rtf) format , each notes document associated their word document in local c:
But when I run my codes with yours, I got “Path/file access error” on ErrorHandler:
'Call LogErrorEx(“Error in: ConvertDocToRtfFile”, SEVERITY_HIGH, doc)
Error Err, Error$ //error coming from this line.
You can see, I commented out the LogErrorEx since I did not download that log tool, but I do not think that matter.
As well, from your codes, I can not find .rtf file format, although I can see “.cd”, but that is not .rtf file, right?
Please let me know how can I make your codes working, thanks
Subject: RE: How to Migrate(convert) notes document to Word?
Hi Peter,
You are likely not specifying the full path "c:\temp" make sure the drive letter is included in the path and the path exists.
OR
You don’t have proper rights to the folder you are trying to right to.
Cheers!
Subject: RE: How to Migrate(convert) notes document to Word?
Hi Mark, thank you again for your quick response, Yes, you are right, it works after I added "c:" in the filepath,
But, the codes does not work for images in the document, basically, I have created a simple document with an image in it, after I ran the code, all contents are converted to word, but not the image. Any idea how to make the image converted as well?
Subject: RE: How to Migrate(convert) notes document to Word?
Peter,
I do not have anything to help with the images. Sorry.
I too have been a happy customer of Integra (For the record… I was a reseller at one time). A number of my clients in the past have used it successfully also.
This can also be achieved with plenty of open source options. So long as you don’t mind a little elbow grease. Just google your own subject/question.
Cheers,
Mark