Technote (FAQ)
Question
You find that when a document is opened via the LotusScript NotesUIWorkspace.EditDocument method, the NotesUIDocument.Editmode=False command cannot act on the opened document. The same command works on documents that were not opened via the EditDocument method. (NotesUIDocument.Editmode=True works on either type of document.). When attempting to set the EditMode property to false, the following error is displayed:
"Document command is not available."
This issue will also happen with newly created documents. For example, the following agent will also produce the same error:
Dim w As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc=w.composedocument("", "", "Main")
uidoc.editmode=False
Answer
This issue has been reported to Lotus Software Quality Engineering. A workaround is to close the uidoc and reopen it in read mode via the NotesUIWorkspace.EditDocument method.
Note: The work around discussed will not revise the behavior if the form's property "Automatically enable Edit Mode" is enabled. For more information on this, refer to document 1094500, "The EditDocument Method Opens a Document in Edit Mode Although Read Mode Is Specified"
Steps to Follow:
1. Declare a temp variable for a NotesDocument (Dim doc as NotesDocument) and get the NotesDocument handle from the existing front end (Set doc=NotesUIDocument.Document).
2. Close the front end document (NotesUIDocument.Close()).
3. Open the document in Read mode from the front end (Call NotesUIWorkspace.EditDocument(False, doc)).
Example:
The following scripts have been copied from a test form that has three actions buttons.
Action 1 Opens existing document in read mode via UI method.
-
Sub Click(Source As Button)
Dim uiwork As New notesuiworkspace
Dim doc As notesdocument
Set doc = uiwork.currentdocument.document
Call uiwork.editdocument(False, doc)
End Sub
Action 2: Toggles edit mode (old method)
-
Sub Click(Source As Button)
Dim uiwork As New notesuiworkspace
Dim uidoc As notesuidocument
Set uidoc = uiwork.currentdocument
If uidoc.editmode Then
uidoc.editmode = False
Else
uidoc.editmode=True
End If
End Sub
Action 3: Toggles edit mode (workaround)
-
Sub Click(Source As Button)
Dim uiwork As New notesuiworkspace
Dim uidoc As notesuidocument
Dim doc As notesdocument
Set uidoc = uiwork.currentdocument
Set doc=uidoc.document
If uidoc.editmode Then
Call uidoc.close()
Call uiwork.editdocument(False, doc)
Else
uidoc.Editmode = True
End If
End Sub
Related Documents:
The EditDocument Method Opens a Document in Edit Mode Although Read Mode Is Specified
Document #: 1094500
EditDocument Method Opens to a New Window Rather than the Frame Indicated in SetTargetFrame Method
Document #: 1084874
Document EditMode Attribute Is Set Incorrectly in QueryModeChange Event
Document #: 1094402
Use of LotusScript Evaluate Function in a Form's PostOpen Event Causes an Unexpected Save Prompt
Document #: 1092209
Rate this page:
Copyright and trademark information
IBM, the IBM logo and ibm.com are trademarks of International Business Machines Corp., registered in many jurisdictions worldwide. Other product and service names might be trademarks of IBM or other companies. A current list of IBM trademarks is available on the Web at "Copyright and trademark information" at www.ibm.com/legal/copytrade.shtml.