Home » Developer & Programmer » Forms » Empty Word document after MailMerge (Forms)
Empty Word document after MailMerge [message #676286] Mon, 27 May 2019 05:33
l.naviglio
Messages: 1
Registered: April 2017
Junior Member
Hi, we have a procedure that open a word .doc template and merge with data in other .doc document to create the final word on user screen.
With Office 2016 it works but with Office 365 the final word document is empty and seems not open the word template at all.

Follow the code we use:
/* Procedura di apertura di un documento WORD mediante l'utilizzo delle OLE. */

	o_object := client_ole2.create_obj('Word.Application');
	client_ole2.set_property(o_object,'Visible',1);
	Client_OLE2.set_property(o_object,'WindowState',2); -- Minimize

  ----------------------------------------------------
  -- Apro il documento template
  ----------------------------------------------------
	o_mydocs   := client_ole2.get_obj_property(o_object,'Documents');
	o_args     := client_ole2.create_arglist;

  client_ole2.add_arg(o_args,par_c_nome_documento);
  o_mydoc    := client_ole2.invoke_obj(o_mydocs,'Open',o_args);
  client_ole2.destroy_arglist(o_args); 	
  
  ----------------------------------------------------------------------------------------
  -- L.Naviglio: BUG Word 2013 - Cambio la modalità di visualizzazione da Lettura a Stampa
  ----------------------------------------------------------------------------------------
  window := client_ole2.get_obj_property(o_mydoc,'ActiveWindow');
  client_ole2.set_property(window,'View',3); --wdPrintView  

	-------------------------------------------
	-- Unione con l'origine dati. 
  ---------------------------------------------  
  o_mrgdoc := client_ole2.get_obj_property(o_mydoc,'MailMerge'); 
  o_args := client_ole2.CREATE_ARGLIST;
  client_ole2.ADD_ARG(o_args,tmp_path||'\origine_dati.doc');
  client_ole2.INVOKE(o_mrgdoc,'OpenDataSource',o_args);
 	client_ole2.destroy_arglist(o_args);

  o_args:=client_ole2.CREATE_ARGLIST;
  client_ole2.INVOKE(o_mrgdoc,'Execute');
  client_ole2.destroy_arglist(o_args);  

	o_args := client_ole2.create_arglist;
  client_ole2.add_arg(o_args,0);
	client_ole2.invoke(o_mydoc, 'Close', o_args);
	client_ole2.destroy_arglist(o_args);

  Client_OLE2.RELEASE_OBJ (o_mydocs);
  Client_OLE2.RELEASE_OBJ (o_mydoc);
  Client_OLE2.RELEASE_OBJ (o_mrgdoc);

Any ideas to resolve?

Thank you so much.
Luca
Previous Topic: block property
Next Topic: FRM-40350 Query Caused No REcords to be retrieved
Goto Forum:
  


Current Time: Fri May 29 06:28:40 CDT 2020