About Me...

NotesRunningLogoRSmall.png

I'm Kathy Brown and I've been an application developer in Lotus Notes/Domino since 2005.

Prior to working in IT, I've had numerous careers including an Investment Analyst and even an Actress (long ago and far away).

And I (try to) love running!

me.jpg

kathy (at) runningnotes (dot) net

On Twitter, kjbrown13

Upcoming Races

Looking 4 Something?

Disclaimer

This is my personal blog. None of the opinions shown here represent those of my employer. In fact, forget I even have an employer. Any examples given here are strictly fictional and hypothetical and it is pure coincidence if they in any way seem like anything in real life.

« It's Official! I'm Published! | Main| Race Coming Up! »

Mail Merge From Lotus To Word

Category Lotus Notes Mail Merge Word
A few months ago I had a development request for a mail merge from Lotus data to Word. Okay, no problem. A lot of the work had already been done for me, in the way of the Microsoft constants database available on OpenNTF. And even MORE of the work was done for me in John Head’s sample app from his Lotusphere presentation about integration of Lotus and Microsoft office. The link actually brings you to his updated presentation from his session at IamLUG, which I attended.

One thing I wanted to add to the code was a header on the final merged document. One bump in the road I ran into, I also wanted to pass a parameter from Lotus to the header in Word. No problem, I can do that. HOWEVER, it wasn’t working. Why? you ask. Well because I’m an idiot. I was using a “directory” type output, which has multiple “records” (in Word-speak) per page. However, the header only occurs once on the page. Even though the field I wanted to use had the same value for each of the merged records, Word is not capable of discerning that. Since Word has no way of determining which record I wanted the value from for the header, it just did nothing.

Once I realized that, I easily got the value I wanted myself using Lotusscript and passed that as a string into my “writeHeader” sub and all was right with the world. Or at least the merged document.

Sub writeHeader (textstring As String) hwd.ActiveDocument.Sections(1).Headers (1).Range.Select ' This gets us into the header for editing hwd.selection.typetext textstring ' enters the passed in string hwd.selection.typeparagraph ' creates a new line hwd.selection.typetext "Test Text" hwd.ActiveWindow.ActivePane.Close ' closes the header pane 'checks if the window panes in Word are split, since code to return to print mode differs if open or not. If hwd.ActiveWindow.View.SplitSpecial = 0 Then hwd.ActiveWindow.ActivePane.View.Type = 3 Else hwd.ActiveWindow.View.Type = 3 End If End Sub

ls2html was brought to you by nsftools.com

One other change I made from the code provided in the constants database was to remove the Merge Wizard from the user interface. In my particular application, I had already formatted the template being used and did not want the users to be able to change the output. Removing the wizard in essence makes Word a nice (did I just say Word is nice, oh dear) reporting tool for Lotus Notes. I can format the output (using a self-made template) much more than I can in Lotus Notes and merge the data into the template. I love Lotus, but there is a, uh, limit to the "reporting" capabilities. So format/create a Word template, use the code from the constants database to merge it, remove the option for the merge wizard to appear, put the code in a button for the user and POOF! Pretty reporting of your Lotus data!

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)