Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using OLE2 + Word 97

Status
Not open for further replies.

alex0909

Programmer
Jul 22, 2002
1
0
0
ES
Hello

I am working with OLE2 (Forms 6) and Word 97, and i'd like do a merge mailing.

I'd like to build a Word table, but i don't know how to go to the next cell.

I've tried a lot of possibilities but i can not do it.

Thank you very much,

Alex
 
Hi,
I have rewriten exampl of creating WordTable.
Code is from testing package. It works fine.
And what about mail merge ? I tried it but it works only
with data in text file. I cant`t set connection string and
SqlStatement through method OpenDataSource.
Have you used MailMerge object ???

palio
mailto:paliok22@yahoo.com

--*--
OBJ_HND OLE2.OBJ_TYPE; /* store the object handle */

procedure testole is
n_row NUMBER;
n_col NUMBER;
begin
filecreate('oletest.doc'); -- set obj_hnd
doevent('AppMaximize',1,null,null,null);
doevent('Font',null,'Arial',null,null);
doevent('FontSize',16,null,null,null);
doevent('Bold',1,null,null,null);
doevent('Italic',1,null,null,null);
doevent('Underline',1,null,null,null);
doevent('Insert',null,'XpertRule to Word - OLE Example Report',null,null);
doevent('InsertPara',null,null,null,null);
doevent('EndOfDocument',1,null,null,null);
doevent('Font',null,'Arial',null,null);
doevent('FontSize',12,null,null,null);
doevent('Bold',0,null,null,null);
doevent('Italic',0,null,null,null);
doevent('CharLeft',1,null,null,null);
doevent('InsertPara',null,null,null,null);
doevent('Insert',null,'Date = ',null,null);
doevent('Insert',null,to_char(SYSDATE,'DD.MM.YYY'),null,null);
doevent('InsertPara',null,null,null,null);
doevent('Insert',null,'Time = ',null,null);
doevent('Insert',null,to_char(SYSDATE,'HH:MM'),null,null);
doevent('InsertPara',null,null,null,null);
doevent('InsertPara',null,null,null,null);
doevent('TableInsertTable',3,'3','6','Auto');
doevent('TableSelectTable',null,null,null,null);
doevent('BorderLineStyle',2,null,null,null);
doevent('BorderOutside',1,null,null,null);
doevent('BorderLineStyle',1,null,null,null);
doevent('BorderInside',1,null,null,null);
doevent('CharLeft',1,null,null,null);
doevent('TableSelectRow',null,null,null,null);
doevent('TableMergeCells',null,null,null,null);
doevent('CharLeft',1,null,null,null);
doevent('TableSelectRow',null,null,null,null);
doevent('Font',null,'Times New Roman',null,null);
doevent('FontSize',18,null,null,null);
doevent('Bold',1,null,null,null);
doevent('Italic',1,null,null,null);
doevent('CenterPara',null,null,null,null);
doevent('CharLeft',1,null,null,null);
doevent('Insert',null,'Title table',null,null);
doevent('NextCell',null,null,null,null);
doevent('TableSelectRow',null,null,null,null);
doevent('Font',null,'Arial',null,null);
doevent('FontSize',12,null,null,null);
doevent('Bold',1,null,null,null);
doevent('Italic',0,null,null,null);
doevent('LeftPara',null,null,null,null);
doevent('CharLeft',1,null,null,null);

For n_col in 1..3
loop
doevent('Insert',null,'head_'||to_char(n_col),null,null);
doevent('NextCell',null,null,null,null);
--doevent('EndOfDocument',1,null,null,null);
doevent('Font',null,'Courier New',null,null);
doevent('FontSize',10,null,null,null);
doevent('Bold',0,null,null,null);
doevent('Italic',0,null,null,null);
doevent('LeftPara',null,null,null,null);
doevent('CharLeft',1,null,null,null);
doevent('NextCell',null,null,null,null);
end loop;

For n_row in 1..5
loop
For n_col in 1..3
loop
doevent('Insert',null,'row_'||to_char(n_row),null,null);
If (n_row = 5) and (n_col = 3) then
null;
Else
doevent('NextCell',null,null,null,null);
End if;
end loop;
end loop;
doevent('TableSelectTable',null,null,null,null);
doevent('CharLeft',1,null,null,null);
doevent('TableSelectRow',null,null,null,null);
doevent('ShadingPattern',7,null,null,null);
doevent('CharLeft',1,null,null,null);
doevent('NextCell',null,null,null,null);
doevent('TableSelectRow',null,null,null,null);
doevent('ShadingPattern',5,null,null,null);
doevent('CharLeft',1,null,null,null);

doevent('EditGoto',null,null,null,null);
--doevent('FileSaveAs',null,'oletest.doc',null,null);
filerelease; --ole2.release_obj(obj_hnd);
end;

procedure DoEvent(sWhat VARCHAR2,n NUMBER,sChar1 VARCHAR2, sChar2 VARCHAR2, sChar3 VARCHAR2) is
arglist ole2.list_type;
begin
arglist := ole2.create_arglist;
if n is not null then
ole2.add_arg (arglist, n);
end if;
if sChar1 is not null then
ole2.add_arg (arglist, sChar1);
end if;
if sChar2 is not null then
ole2.add_arg (arglist, sChar2);
end if;
if sChar3 is not null then
ole2.add_arg (arglist, sChar3);
end if;
ole2.invoke (obj_hnd, sWhat, arglist);
ole2.destroy_arglist (arglist);
exception
when others then
message('doevent:'||sWhat||' n:'||to_char(n)||' S1:'||sChar1||' S2:'||sChar2||' S3:'||sChar3);
raise;
end;

procedure FileCreate (fname in varchar2) is
arglist ole2.list_type;
begin
obj_hnd := ole2.create_obj ('Word.Basic');
arglist := ole2.create_arglist;
ole2.add_arg (arglist, fname);
ole2.invoke (obj_hnd, 'fname', arglist);
ole2.invoke (obj_hnd, 'FileNewDefault');
ole2.invoke(obj_hnd, 'AppShow');
ole2.destroy_arglist (arglist);
end;
--*--
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top