• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 518
  • Last Modified:

How to open Object which is stored in Richtext Field.

Dear Expert,

We are using Lotus-Notes 4.6.1. We are facing some problem with opening the word file object stored in the Richtext field of the document.

i.e Field "rt" is the Richtext field in the form, inwhich the word object is created.

1->      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      dim wordobj as variant

      Set uidoc = workspace.CurrentDocument
      Call uidoc.GotoField("rt")
      Set wordobj = uidoc.CreateObject("Word Doc","word.document")

Above code is used to create the word object in the document's RichText field, at the creation time of the document When user press the Launch Word Button.The word application is automatically open with blank document.

To retrive the created word document we use the following script to get the word object stored in the richtext field of the document.

2->      Dim workspace As New NotesUIWorkspace
      Dim uidoc As NotesUIDocument
      dim wordobj as variant

      Set uidoc = workspace.CurrentDocument
      Call uidoc.GotoField("rt")
      Set wordobj = uidoc.GetObject( "Word Doc" )

the wordobj is set but we can't see the already created word document.

We want the things like: when the user press the button the "2->" script runs it opens the word application(we can do this thing) with the existing word document which is sotred in the richtext field.

We know that this thing can be done through Form's Launch Tab option, but we can't use that option.

When we make right click to the Richtext field, in which the word document is created we have many options, two of them is "Edit" and "Open" by clicking "Open" existing word document is opened with the Word application. we want to minimize the click by just pressing one button called "Open Attach Word Document". In that button the "2->" script is written.

With Regards,

Nilesh Shah.
1 Solution
As far as I know the GetObject method only opens or returns the currently open instance of the OLE application. It doesn't actually perform any methodm to open a particular file. Look at the NotesEmbeddedObject class and the Activate method. This may give you what you want.
AurokripaAuthor Commented:
Hi, ghart.

Thanks for your response. I can do the partial things which i exactly want. I can open the existing embedded object using Notes Embedded Class, but now the problem is the existing embedded object doesn't sustain at word application. The word application opens with our embedded object(stores in richtext field) but when the script is finished then the document is closed from the word application.

I am using the following script:

Dim workspace As New NotesUIWorkspace
     Dim uidoc As NotesUIDocument
     Dim doc As NotesDocument
     Dim ritem As Variant
     Dim wordobj As NotesEmbeddedObject
     Dim handle As Variant
     Set uidoc = workspace.CurrentDocument
     Set doc = uidoc.document
     Call uidoc.GoToField("richtext")
     Set ritem = doc.GetFirstItem("richtext")
     Set wordobj = ritem.GetEmbeddedObject("Word Doc")    
     Set handle = wordobj.Activate(True)
     Call wordobj.Doverb( "&Open" )
End Sub

Waiting for your positive reply,

Nilesh Shah
If I understand you right, Word opens with the document but it gets closed when the execution of the script is finished ?
You might want to take a look at the Notes help of the Yield function and the ActivateApp function. Maybe this is was you need.

Sorry if I misunderstood.
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

Try to declare wordObj and handle as global variables, you might have to declare some of the other variables as global as well. The reason your word document closes is that wordObj gets out of scope when your button is finished with its script. But if you declare them as global, you will merely use existing variables.

Hope this solves your problem.
Harald R.

AurokripaAuthor Commented:
Dear Expert Paebdb,

      Thank you very very much for your valuable reply, you understand the right what i mean to say. Through the Activate method of the NotesEmbeddedObject the Microsoft Word is open with the Word document which is store in the richtext field(according to the reply of ghart).

      I refere the Yield and ActivateApp function of LotusScript, But the problem is, it uses the API (GetModuleUsage) to check whether the Word is open or not?  For that you have to generate one integer variable using shell method. In our case we already have the word object (which can be get by getobject method.). so can u please guide me (with the code) that how can i use Yield function with already created object.

      I am using the script which is written above. please refere it.

Awaiting for your positive and valuable reply.

Nilesh Shah
AurokripaAuthor Commented:

Thanks a lot for guiding us with a simple solution. I think you must have worked hard and a lot with Notes and must have faced such problems. We are so greatful to you for giving us a perfect answer. We hope in future you will guide us when ever we required your help.

Thanks a lot again,

With regards,

Nilesh shah

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now