Home » Developer & Programmer » Forms » Protect Document using Webutil
Protect Document using Webutil [message #256062] Thu, 02 August 2007 21:10 Go to next message
Prasad01
Messages: 22
Registered: August 2007
Junior Member
Hi,
I am trying to insert section break and protect a word document opened using Webutil.
But its not working. Here is the code:
/* Insert Section Break */
v_args:=CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(v_args,6); --Contiunous Section Break -
CLIENT_OLE2.INVOKE(:global.v_doc_word,'InsertBreak',v_args);
CLIENT_OLE2.DESTROY_ARGLIST(v_args);

/* Protect the Section */
v_args:=CLIENT_OLE2.CREATE_ARGLIST;
CLIENT_OLE2.ADD_ARG(v_args,0); -- ProtectedForForms = True -
CLIENT_OLE2.INVOKE(:global.v_doc_word,'ProtectedForForms',v_args);
CLIENT_OLE2.DESTROY_ARGLIST(v_args);

Its neither inserting a section nor protecting.
Is there something I am missing out?
Any input would be highly appreciated.
Cheers
Prasad.
Re: Protect Document using Webutil [message #256128 is a reply to message #256062] Fri, 03 August 2007 01:58 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Did you insert any data after you did the insert section?

David
Re: Protect Document using Webutil [message #256545 is a reply to message #256128] Sun, 05 August 2007 18:19 Go to previous messageGo to next message
Prasad01
Messages: 22
Registered: August 2007
Junior Member
No I am not inserting any data after I insert the section.
Re: Protect Document using Webutil [message #256619 is a reply to message #256545] Mon, 06 August 2007 02:24 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
Try inserting a couple of 'blank' lines then save the file and see what happens.

David
Re: Protect Document using Webutil [message #256623 is a reply to message #256619] Mon, 06 August 2007 02:32 Go to previous messageGo to next message
Prasad01
Messages: 22
Registered: August 2007
Junior Member
I think the problem is not that, the problem is it seems that it is not getting the handle for the sections
Here is my new code:
MySections :=  CLIENT_OLE2.GET_OBJ_PROPERTY(active_doc,'Sections');
Sections_Count :=CLIENT_OLE2.GET_NUM_PROPERTY(MySections,'Count'); 
While Sections_Count > 0 Loop 
v_args:=CLIENT_OLE2.CREATE_ARGLIST; 
CLIENT_OLE2.ADD_ARG(v_args, Sections_count);  
mysection:=CLIENT_OLE2.INVOKE_OBJ(MySections,'Item',args);
CLIENT_OLE2.DESTROY_ARGLIST(args); 
--get the Index or Number of Section
section_index:=CLIENT_OLE2.GET_CHAR_PROPERTY(mysection,'Index');

If section_index = 1 then
  v_args:=CLIENT_OLE2.CREATE_ARGLIST; 
  CLIENT_OLE2.ADD_ARG(v_args,0);  -- ProtectedForForms = True  -
  CLIENT_OLE2.INVOKE(mysection,'ProtectedForForms',v_args);
  CLIENT_OLE2.DESTROY_ARGLIST(v_args); 
ElsIf section_index = 2 then
  v_args:=CLIENT_OLE2.CREATE_ARGLIST; 
  CLIENT_OLE2.ADD_ARG(v_args,1);  -- ProtectedForForms = False-
  CLIENT_OLE2.INVOKE(mysection,'ProtectedForForms',v_args);
  CLIENT_OLE2.DESTROY_ARGLIST(v_args); 
ElsIf section_index = 3 then
v_args:=CLIENT_OLE2.CREATE_ARGLIST; 
  CLIENT_OLE2.ADD_ARG(v_args,0);  -- ProtectedForForms = True  -
  CLIENT_OLE2.INVOKE(mysection,'ProtectedForForms',v_args);
  CLIENT_OLE2.DESTROY_ARGLIST(v_args); 
End If;	
	sections_Count :=sections_Count-1; 
End Loop; 

After this I am protecting the document, now whats happening is its only protecting the Header leaving other sections open

Upd mod: Please use 'code' tags.

[Updated on: Mon, 06 August 2007 02:43] by Moderator

Report message to a moderator

Re: Protect Document using Webutil [message #256629 is a reply to message #256623] Mon, 06 August 2007 02:44 Go to previous messageGo to next message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
How many sections are there?

David
Re: Protect Document using Webutil [message #256827 is a reply to message #256629] Mon, 06 August 2007 17:51 Go to previous messageGo to next message
Prasad01
Messages: 22
Registered: August 2007
Junior Member
There are 3 sections
Re: Protect Document using Webutil [message #256830 is a reply to message #256827] Mon, 06 August 2007 18:57 Go to previous messageGo to next message
Prasad01
Messages: 22
Registered: August 2007
Junior Member
When I put the following vb code in a macro in the document it works fine, exactly as I want
ActiveDocument.Sections(1).ProtectedForForms = True
ActiveDocument.Sections(2).ProtectedForForms = False
ActiveDocument.Sections(3).ProtectedForForms = True

But I dont want to use macros.
How can we convert this in PL/SQL
Re: Protect Document using Webutil [message #256894 is a reply to message #256830] Tue, 07 August 2007 00:59 Go to previous message
djmartin
Messages: 10180
Registered: March 2005
Location: Canberra ACT Australia
Senior Member
Account Moderator
The following is your code from above:
BEGIN
  MySections      := Client_ole2.Get_obj_Property (Active_Doc, 'Sections');
  Sections_Count  := Client_ole2.Get_num_Property (MySections, 'Count');
  WHILE Sections_Count > 0
  LOOP
    v_args          := Client_ole2.Create_argList;
    Client_ole2.Add_arg (v_args, Sections_Count);
    MySection       := Client_ole2.Invoke_obj (MySections, 'Item', args);
    Client_ole2.Destroy_argList (args);
    --get the Index or Number of Section
    Section_Index   := Client_ole2.Get_Char_Property (MySection, 'Index');
    IF Section_Index = 1 THEN
      v_args  := Client_ole2.Create_argList;
      Client_ole2.Add_arg (v_args, 0);   -- ProtectedForForms = True  -
      Client_ole2.Invoke (MySection, 'ProtectedForForms', v_args);
      Client_ole2.Destroy_argList (v_args);
    ELSIF Section_Index = 2 THEN
      v_args  := Client_ole2.Create_argList;
      Client_ole2.Add_arg (v_args, 1);   -- ProtectedForForms = False-
      Client_ole2.Invoke (MySection, 'ProtectedForForms', v_args);
      Client_ole2.Destroy_argList (v_args);
    ELSIF Section_Index = 3 THEN
      v_args  := Client_ole2.Create_argList;
      Client_ole2.Add_arg (v_args, 0);   -- ProtectedForForms = True  -
      Client_ole2.Invoke (MySection, 'ProtectedForForms', v_args);
      Client_ole2.Destroy_argList (v_args);
    ELSE
      message('Section_index='||to_char(Section_Index);pause;
    END IF;
    Sections_Count  := Sections_Count - 1;
  END LOOP;
END;
I suggest adding a 'debug message' statement to it so that you can verify that the numbering is that which you are expecting.

David
Previous Topic: How to show report output from a plsql proc back on a form
Next Topic: populate record group
Goto Forum:
  


Current Time: Fri Dec 09 03:43:20 CST 2016

Total time taken to generate the page: 0.14823 seconds