Home » Developer & Programmer » Forms » How to set the header for second page
How to set the header for second page [message #423372] |
Wed, 23 September 2009 14:05 |
bsingam
Messages: 7 Registered: March 2009
|
Junior Member |
|
|
Hello all,
I'm trying to set different header for first page and page number should starts from second page.
Below is the sample code to set the header for each and every page.
DECLARE
hApplication OLE2.OBJ_TYPE;
hWindow OLE2.OBJ_TYPE;
hPane OLE2.OBJ_TYPE;
hView OLE2.OBJ_TYPE;
hDocuments OLE2.OBJ_TYPE;
hDocument OLE2.OBJ_TYPE;
hSelection OLE2.OBJ_TYPE;
hParagraphFormat OLE2.OBJ_TYPE;
hRange OLE2.OBJ_TYPE;
hFields OLE2.OBJ_TYPE;
hFont OLE2.OBJ_TYPE;
args OLE2.LIST_TYPE;
wdAlignParagraphLeft CONSTANT number(3) := 0;
wdAlignParagraphCenter CONSTANT number(3) := 1;
wdAlignParagraphRight CONSTANT number(3) := 2;
wdSeekCurrentPageHeader CONSTANT number(3) := 9;
wdSeekCurrentPageFooter CONSTANT number(3) := 10;
wdSeekMainDocument CONSTANT number(3) := 0;
wdFieldPage CONSTANT number(3) := 33;
wdFieldNumPages CONSTANT number(3) := 26;
wdPageBreak CONSTANT number(3) := 7;
wdStory CONSTANT number(3) := 6;
myTab CONSTANT varchar2(1) := chr(9);
myBlue CONSTANT number(8) := 16711680; --FF0000
myGreen CONSTANT number(8) := 65280; --00FF00
myRed CONSTANT number(8) := 255; --0000FF
myDkGreen CONSTANT number(8) := 32768; --008000
myBlack CONSTANT number(8) := 0; --000000
myText varchar2(2000);
BEGIN
hApplication:=OLE2.CREATE_OBJ('Word.Application');
OLE2.SET_PROPERTY(hApplication, 'Visible', 1);
hDocuments := OLE2.GET_OBJ_PROPERTY(hApplication, 'Documents');
hDocument := OLE2.INVOKE_OBJ(hDocuments, 'Add');
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Create Header and Footer
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
hWindow := OLE2.GET_OBJ_PROPERTY(hApplication, 'ActiveWindow');
hPane := OLE2.GET_OBJ_PROPERTY(hWindow, 'ActivePane' );
hView := OLE2.GET_OBJ_PROPERTY(hPane, 'View' );
---- Header Section ---
OLE2.SET_PROPERTY(hView, 'SeekView', wdSeekCurrentPageHeader);
hSelection := OLE2.GET_OBJ_PROPERTY(hApplication, 'Selection');
hFont := OLE2.GET_OBJ_PROPERTY(hSelection, 'Font');
OLE2.SET_PROPERTY(hFont, 'Name', 'Times New Roman');
OLE2.SET_PROPERTY(hFont, 'Size', 10);
OLE2.SET_PROPERTY(hFont, 'Bold', FALSE);
OLE2.SET_PROPERTY(hFont, 'Color', MyBlue );
hParagraphFormat := OLE2.GET_OBJ_PROPERTY(hSelection, 'ParagraphFormat');
OLE2.SET_PROPERTY(hParagraphFormat, 'Alignment', wdAlignParagraphCenter);
OLE2.RELEASE_OBJ(hParagraphFormat);
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'This is a');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.INVOKE(hSelection, 'TypeParagraph');
OLE2.SET_PROPERTY(hFont, 'Size', 16);
OLE2.SET_PROPERTY(hFont, 'Bold', TRUE);
OLE2.SET_PROPERTY(hFont, 'Color', MyDkGreen );
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'Test Header');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
---- Footer Section ----
OLE2.SET_PROPERTY(hView, 'SeekView', wdSeekCurrentPageFooter);
hParagraphFormat := OLE2.GET_OBJ_PROPERTY(hSelection, 'ParagraphFormat');
OLE2.SET_PROPERTY(hParagraphFormat, 'Alignment', wdAlignParagraphCenter);
OLE2.RELEASE_OBJ(hParagraphFormat);
hFields := OLE2.GET_OBJ_PROPERTY(hSelection, 'Fields');
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'Page ');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
hRange := OLE2.GET_OBJ_PROPERTY(hSelection, 'Range');
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG_OBJ(args, hRange);
OLE2.ADD_ARG(args, wdFieldPage);
OLE2.INVOKE(hFields, 'Add', args );
OLE2.DESTROY_ARGLIST(args);
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, ' of ');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
hRange := OLE2.GET_OBJ_PROPERTY(hSelection, 'Range');
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG_OBJ(args, hRange);
OLE2.ADD_ARG(args, wdFieldNumPages);
OLE2.INVOKE(hFields, 'Add', args );
OLE2.DESTROY_ARGLIST(args);
OLE2.RELEASE_OBJ(hRange);
OLE2.RELEASE_OBJ(hFields);
OLE2.SET_PROPERTY(hView, 'SeekView', wdSeekMainDocument);
OLE2.RELEASE_OBJ(hView);
OLE2.RELEASE_OBJ(hPane);
OLE2.RELEASE_OBJ(hWindow);
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Insert Text
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
hFont := OLE2.GET_OBJ_PROPERTY(hSelection, 'Font');
OLE2.SET_PROPERTY(hFont, 'Name', 'Arial');
OLE2.SET_PROPERTY(hFont, 'Size', 12);
OLE2.SET_PROPERTY(hFont, 'Bold', FALSE );
OLE2.SET_PROPERTY(hFont, 'Color', myBlack );
OLE2.INVOKE(hSelection, 'TypeParagraph');
myText := myTab || 'This text is on the ';
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, myText);
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.SET_PROPERTY(hFont, 'Bold', TRUE);
OLE2.SET_PROPERTY(hFont, 'Color', myRed);
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'first ');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.SET_PROPERTY(hFont, 'Bold', FALSE);
OLE2.SET_PROPERTY(hFont, 'Color', myBlack );
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'page.');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, wdPageBreak);
OLE2.INVOKE(hSelection, 'InsertBreak', args);
OLE2.DESTROY_ARGLIST(args);
----page 2
myText := myTab || 'This text is on the ';
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, myText );
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.SET_PROPERTY(hFont, 'Bold', TRUE);
OLE2.SET_PROPERTY(hFont, 'Color', myBlue);
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'second ');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.SET_PROPERTY(hFont, 'Bold', FALSE);
OLE2.SET_PROPERTY(hFont, 'Color', myBlack );
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, 'page.');
OLE2.INVOKE(hSelection, 'TypeText', args);
OLE2.DESTROY_ARGLIST(args);
---- go to the top of the first page
args := OLE2.CREATE_ARGLIST;
OLE2.ADD_ARG(args, wdStory);
OLE2.INVOKE(hSelection, 'HomeKey', args);
OLE2.DESTROY_ARGLIST(args);
OLE2.RELEASE_OBJ(hFont);
OLE2.RELEASE_OBJ(hSelection);
OLE2.RELEASE_OBJ(hDocument);
OLE2.RELEASE_OBJ(hDocuments);
OLE2.RELEASE_OBJ(hApplication);
END;
Please help me out
Thanks,
Bhavana
[EDITED by LF: applied [code] tags]
[Updated on: Wed, 23 September 2009 23:58] by Moderator Report message to a moderator
|
|
|
|
|
|
Goto Forum:
Current Time: Tue Feb 04 02:52:31 CST 2025
|