Home > Software engineering >  [for] VC editing word tables, how to make the table in the middle
[for] VC editing word tables, how to make the table in the middle

Time:01-03

Basic functions are realized, now just center the word form, have a friend will be glad to please, thank you, pay attention to is to put the table in the middle, not center the text,

Part of the code in the following, if you need other information, please contact!

Cell phones, WeChat 13522968283, can be paid!

Void CWordtestDlg: : OnNewDoc ()
{
COleVariant vTrue (TRUE) (short);
COleVariant vFalse (FALSE) (short);
COleVariant vOpt ((long) DISP_E_PARAMNOTFOUND VT_ERROR);

//////////////////////////////////////////////////////////////////////////
//start a new Microsoft Word instance
_Application oWordApp;
if (! OWordApp. CreateDispatch (" Word. Application ", NULL))
{
AfxMessageBox (CreateDispatch "failed", MB_OK | MB_SETFOREGROUND);
return;
}
OWordApp. SetVisible (TRUE);


//////////////////////////////////////////////////////////////////////////
//create a new word document
The Documents oDocs=oWordApp. GetDocuments ();
_Document oDoc=oDocs. Add (vOpt vOpt, vOpt, vOpt);

//add text to the word document
Selection oSel=oWordApp. GetSelection ();

_Font f=oSel. GetFont ();


Com.lowagie.text.paragraph format=oSel. GetParagraphFormat ();//set the format


Format. SetAlignment (1);//center
Format. SetLineSpacingRule (4);
Format. SetLineSpacing (13);

F.S etSize (12);
F.S etBold (1);
OSel. TypeParagraph ();
OSel. TypeText (" western European g8 15 days trip ");
OSel. TypeParagraph ();
F.S etSize (9);
F.S etBold (0);

OSel. TypeParagraph ();
OSel. WholeStory ();

//set the font - old
/* _Font font (oSel GetFont ());
//the font. SetColor (RGB (0, 255));
The font, SetColor (RGB (0, 0));
The font. The SetSize (14. F);
The font. SetBold (1);
OSel. SetFont (font); */



///table 1

OSel. EndKey (COleVariant ((short) wdStory), COleVariant ((short) wdMove));
The Range of Rng=oSel. GetRange ();
Tables Tbls=oDoc. GetTables ();
Table Tb0=Tbls. Add (Rng, 16, 5, vOpt, vOpt);
Borders bords0=Tb0. GetBorders ();
Bords0. SetOutsideLineStyle (wdLineStyleSingle);//set the border attribute
Bords0. SetOutsideColorIndex (wdBlack);//border color
Bords0. SetOutsideLineWidth (wdLineWidth150pt);//border width
Bords0. SetInsideLineStyle (wdLineStyleSingle);//frame attribute
Bords0. SetInsideColorIndex (wdBlack);//frame color


F.S etBold (1);
The Columns c=oSel. GetColumns ();
C.s. etWidth (40);
OSel. TypeText (_T (" the first X days "));
OSel. MoveRight (COleVariant ((short) 1), COleVariant ((short) 1), COleVariant ((short) 0));
F.S etBold (1);
C.s. etWidth (50);
OSel. TypeText (_T (" date "));
OSel. MoveRight (COleVariant ((short) 1), COleVariant ((short) 1), COleVariant ((short) 0));
F.S etBold (1);
C.s. etWidth (260);
OSel. TypeText (_T (" schedule "));
OSel. MoveRight (COleVariant ((short) 1), COleVariant ((short) 1), COleVariant ((short) 0));
F.S etBold (1);
C.s. etWidth (40);
OSel. TypeText (_T (" accommodation "));
OSel. MoveRight (COleVariant ((short) 1), COleVariant ((short) 1), COleVariant ((short) 0));
F.S etBold (1);
//c.s. etWidth (30);
C.s. etWidth (100);
OSel. TypeText (_T (" dining "));
OSel. MoveDown (COleVariant ((short) 4), COleVariant ((short) 1), COleVariant ((short) 0));

CodePudding user response:

Mobile phone, WeChat 13522968273, the above write wrong, is this, sorry!
  • Related