Word Export Issues

Following is the code I have written to export Notes documents to Microsoft Word. I have a couple of issues when running this code:

  1. I keep getting a message about saving redaction.dot when I attempt to close the newly created Word document.

  2. The newly created Word document does nto open with “Open” … it has been corrupted somehow and I must use FILE-OPEN AND REPAIR and re-save it to make it usable. The error references “Table end-of-cell markers”.

I have searched through this forum as well as the Domino 4-5 forum and have not had any luck. Is there someone out there who can assist? I have a hot project that is rolling out very soon and I have to have this functionality available.

TIA,

mvp

Sub Initialize

'Declare object variables

Dim ws As New NotesUIWorkspace

Dim uidoc As NotesUIDocument

Dim doc As NotesDocument

Dim WordAppl As Variant

Dim WordDoc As Variant

'Initialize OLE object

Set WordAppl = CreateObject("Word.Application") 

WordAppl.visible = False

’ Creates a new Word document

Set WordDoc = WordAppl.Documents.Add()

'Initialize database object and uidoc object

Set uidoc = ws.editdocument(True)

Set doc = uidoc.document

’ get values for filename 'new segment

client = doc.company(0)

casenumber = doc.CaseNum(0)

emplnum = doc.PersNum(0)



casefile = client & "_" & casenumber & "_" & emplnum

’ Makes sure the Notes document is not in edit mode

uidoc.EditMode = False

'Select Entire document and copy to the clipboard

Call uidoc.SelectAll

Call uidoc.Copy

'Paste from the clipboard to the word document

WordAppl.Selection.Paste



WordDoc.saved = True ' prevents 'Save?' dialog

WordAppl.Visible = True

WordDoc.SaveAs("C:\" & casefile)

WordAppl.Quit

Set WordAppl = Nothing 'release the reference in LotusScript

Call uidoc.close

End Sub

Subject: Word Export Issues

It looks like there is a template involved (called redaction.dot). Maybe it is not accessable from the Notes client (sahred device, access rights?).

What happens when you omit the pasting in Word? And what happens when you do not quit Word, but unhide it?

Subject: RE: Word Export Issues

Hi Rob,

If I leave out the paste, then the document contents do not get put into the Word document (of course), but I can open the empty Word document just fine. Also, I still receive the error messages concerning redaction.dot.

If I omit the quit, The Word document with the pasted notes document, are left open. When I press “X” to close teh document:

  1. I receive the promot: “Word cannot save this file because it is already open elsewhere. (C:\Program Files\ … \Redaction.dot)”

  2. I click OK to exit this dialog and receive the prompt: “Do you want to save the changes to Redaction.dot?”

  3. I respond NO to this prompt.

  4. When I attempt to open the Word document, I receive the following error:

Word is unable to read thsi document. It may be corrupt. Try one or more of the following:

** Open and Repair the file

** Open the file with the Text Recovery converter

Open and Repair allows me to open the document as I indicated in my initial post. I have not attempted the 2nd.

Thanks for your assistance.

Mary

Subject: RE: Word Export Issues

Hi Mary,

So you problem is in that template (or in the normal.dot that might invoke this Redaction.dot) and not in your lotusscript.

It is always a good suggestion to manually do what you have programmed in your script to locate any possible problems.

Subject: RE: Word Export Issues

Rob, I uninstalled the add-in Redacrion yesteray and that resolved one problem. I still am having the issue with corrupted Word documents being created and only when the entire document is being copied/pasted. If I copy individual fields, I do not have an issue.

The documents I am trying to move to Word are varied in fields, etc., so copying individually is not an option.

Any suggestions?

Thanks,

Mary

Subject: RE: Word Export Issues

There is an attribute Items in the NotesDocument class that can be looped through and can handle any number of items in the document.