Link to home
Start Free TrialLog in
Avatar of Aurokripa
Aurokripa

asked on

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.

TIA,
With Regards,

Nilesh Shah.
Avatar of ghart
ghart

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.
Avatar of Aurokripa

ASKER

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

TIA,
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.
ASKER CERTIFIED SOLUTION
Avatar of HaraldR
HaraldR

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
To,
HaraldR

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