Passing Text from Forms to a Word Document.

From: cconway <conway-ce_at_erols.com>
Date: 2000/05/03
Message-ID: <8epe85$i01$1_at_bob.news.rcn.net>#1/1


[Quoted] I've successfully passed a single text item to a bookmark in Word 2000. However, I'm having trouble passing multiple items to multiple bookmarks in the same document. Here's my souce code:

DECLARE

MyApplication OLE2.OBJ_TYPE;
MyDocuments OLE2.OBJ_TYPE;
MyDocument OLE2.OBJ_TYPE;
MySelection OLE2.OBJ_TYPE;

v_ccname varchar2 (15);
v_addr1 varchar2 (40);

  • Declare handle to the OLE argument list

args OLE2.LIST_TYPE;

BEGIN

  • break on cc_code skip new page select cc_name, cc_ad1 into v_ccname, v_addr1 from ocme_2k.cme_cityco where cc_code = 222 or cc_code = 144 order by cc_name;
  • Create the Word.Application object and make Word visible
  • by setting the 'Visible' property to true

MyApplication:=OLE2.CREATE_OBJ('Word.Application'); OLE2.SET_PROPERTY(MyApplication, 'Visible', 1);

  • get a handle on Documents collection

MyDocuments:=OLE2.GET_OBJ_PROPERTY(MyApplication, 'Documents');

  • Open a new document

args:=OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'c:\ocmeis_prod\pay_letter.doc'); Mydocument :=OLE2.INVOKE_OBJ(MyDocuments,'Open',args); OLE2.DESTROY_ARGLIST(args);

  • get a handle on Selection object

MySelection:=OLE2.GET_OBJ_PROPERTY(MyApplication, 'Selection');

  • Navigate to the Bookmark called 'MyBookmark'
  • VBA Syntax: Selection.Goto(What, Which, Count, Name)
  • Which, Count are optional and are specified only because the values
  • of the parameters are position dependent.

args:=OLE2.CREATE_ARGLIST;

OLE2.ADD_ARG(args, -1); -- What => constant 'wdGoToBookmark' = -1
OLE2.ADD_ARG(args,0); -- Which
OLE2.ADD_ARG(args,0); -- Count
OLE2.ADD_ARG(args, 'ccname'); -- Name => bookmark name

-- OLE2.ADD_ARG(args, 'addr1'); -- Name => bookmark name
OLE2.INVOKE(MySelection,'GoTo',args);
  • Insert some text at the bookmark location

OLE2.SET_PROPERTY(MySelection, 'Text', v_ccname);
-- OLE2.SET_PROPERTY(MySelection, 'Text', v_addr1);

  • Release the OLE objects OLE2.RELEASE_OBJ(MySelection); OLE2.RELEASE_OBJ(MyDocument); OLE2.RELEASE_OBJ(MyDocuments); OLE2.RELEASE_OBJ(MyApplication);

END; Can anyone provide any assistance on how to do this. When I try, I get "FRM-40735: WHEN-BUTTON-PRESSED trigger raised unhandled exception ORA-01422." Advance thanks for your help.

P.S. Please email any responses to cconway_at_vdh.state.va.us. Received on Wed May 03 2000 - 00:00:00 CEST

Original text of this message