Client_Ole2 commands for Word.Application
480816Jan 5 2006 — edited Feb 24 2006I need a CLIENT_OLE2 code example that inserts a file(s) into a New Word Document.
I have old OLE2 code that I'm re-writing using Client_OLE2 that Opens Word and builds a letter template. The letter(s) may consist of multiple parts I.E. Top, Mid, Bottom.
A sample of my old code invoking the InsertFile method of Word.Application
looks like this:
APPLICATION := CLIENT_OLE2.CREATE_OBJ('Word.Application');
CLIENT_OLE2.SET_PROPERTY(APPLICATION,'Visible', 1);
--- insert top of letter (date, name, adress etc...)
args := CLIENT_OLE2.create_arglist;
CLIENT_OLE2.add_arg(args,:GLOBAL.DOC_PATH||'TOP.DOC');
CLIENT_OLE2.invoke(application,'InsertFile',args);
CLIENT_OLE2.destroy_arglist(args);
My re-write is below:
APPLICATION := CLIENT_OLE2.CREATE_OBJ('Word.Application');
CLIENT_OLE2.SET_PROPERTY(APPLICATION,'Visible', 1);
SEL := CLIENT_OLE2.GET_OBJ_PROPERTY(APPLICATION,'SELECTION');
--- insert top of letter (date, name, adress etc...)
sel := CLIENT_OLE2.GET_OBJ_PROPERTY(application,'SELECTION');
args := CLIENT_OLE2.create_arglist;
CLIENT_OLE2.add_arg(args,:GLOBAL.DOC_PATH||'TOP.DOC');
CLIENT_OLE2.invoke(SEL,'InsertFile',args);
CLIENT_OLE2.destroy_arglist(args);
I can't figure out what I'm missing.
Thanks