problem in OLE2 and how can i add a line to a word file using OLE2 (merged) [message #181709] |
Tue, 11 July 2006 04:03 |
emadbsb
Messages: 334 Registered: May 2005 Location: egypt
|
Senior Member |
|
|
hii all
i have a problem in my code using ole2 objects
i am using word 2000
the code is
DECLARE
DOC OLE2.OBJ_TYPE;
DOC1 OLE2.OBJ_TYPE;
DOC2 OLE2.OBJ_TYPE;
args OLE2.LIST_TYPE;
workbook OLE2.OBJ_TYPE;
workbooks OLE2.OBJ_TYPE;
BEGIN
doc :=OLE2.CREATE_OBJ ('WORD.APPLICATION');
OLE2.SET_PROPERTY(DOC,'VISIBLE',1);
MESSAGE ('1');
MESSAGE ('1');
DOC1 := OLE2.GET_OBJ_PROPERTY(DOC,'Documents');
MESSAGE ('2');
MESSAGE ('2');
DOC2 := OLE2.INVOKE_OBJ(DOC1,'ADD');
workbook := OLE2.GET_OBJ_PROPERTY (DOC,'SELECTION');
OLE2.SET_PROPERTY(WORKBOOK,'TEXT','HIIIIIII');
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG (ARGS,'D:\NEWWWW.DOC');
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG (ARGS,0 );
OLE2.INVOKE (DOC2,'CLOSE',ARGS);
OLE2.RELEASE_OBJ (DOC2);
OLE2.RELEASE_OBJ (DOC1);
OLE2.RELEASE_OBJ (workbook);
OLE2.INVOKE (DOC,'QUIT');
END;
i insisted on putting "message (1) and message (2)"
but after running my application by pressing a button on the form
the message ('1') is displayed
while message ('2') is not displayed
and i got the error of
when button pressed trigger raised unhandled exception
is there any error in this
DOC1 := OLE2.GET_OBJ_PROPERTY(DOC,'Documents');
[Updated on: Tue, 11 July 2006 04:04] Report message to a moderator
|
|
|
how can i add a line to a word file using OLE2 [message #181742 is a reply to message #181709] |
Tue, 11 July 2006 06:46 |
emadbsb
Messages: 334 Registered: May 2005 Location: egypt
|
Senior Member |
|
|
Hii all
I created i have this code
DECLARE
APP OLE2.OBJ_TYPE;
DOCS OLE2.OBJ_TYPE;
DOC OLE2.OBJ_TYPE;
DOC2 OLE2.OBJ_TYPE;
args OLE2.LIST_TYPE;
SELECTION OLE2.OBJ_TYPE;
SELECTION1 OLE2.OBJ_TYPE;
workbooks OLE2.OBJ_TYPE;
BEGIN
APP :=OLE2.CREATE_OBJ ('WORD.APPLICATION');
OLE2.SET_PROPERTY(APP,'VISIBLE',1);
DOCS := OLE2.GET_OBJ_PROPERTY(APP,'Documents');
DOC := OLE2.INVOKE_OBJ(DOCS,'ADD');
SELECTION := OLE2.GET_OBJ_PROPERTY (APP,'SELECTION');
OLE2.SET_PROPERTY(SELECTION,'TEXT','hiiiii');
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG (ARGS,'D:\NEWWWW.DOC');
OLE2.INVOKE (DOC,'SAVEAS',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
ARGS := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG (ARGS,0 );
OLE2.INVOKE (DOC,'CLOSE',ARGS);
OLE2.DESTROY_ARGLIST(ARGS);
OLE2.RELEASE_OBJ (SELECTION);
OLE2.RELEASE_OBJ (DOC);
OLE2.RELEASE_OBJ (DOCS);
OLE2.INVOKE (APP,'QUIT');
END;
this code works right with no problem
and it insert to the word file NEWWWW.doc the word "hiiiii"
now i want to add another line in the same file holding the word "hello"
so that the file looks like
hiiiii
hello
Thanks for Everyone helped and helping me
[Updated on: Tue, 11 July 2006 06:49] Report message to a moderator
|
|
|
Re: problem in OLE2 [message #182384 is a reply to message #181709] |
Fri, 14 July 2006 08:53 |
|
djmartin
Messages: 10181 Registered: March 2005 Location: Surges Bay TAS Australia
|
Senior Member Account Moderator |
|
|
I suggest that you search this forum for 'ole'. There are plenty on working examples.
Have you installed webutil on your PC?
David
|
|
|