Home > Software engineering >  How to use the generated c word document set to horizontal, and columns into 2 bar
How to use the generated c word document set to horizontal, and columns into 2 bar

Time:10-11

How to use the word documents generated by the c + + will be set to horizontal, then column into a 2 column
[11] set the width of the number of columns and column
Here it is important to note that the add function of logic
1 SectionsPtr word_sections=doc - & gt; GetSections ();
2 long num=word_sections - & gt; GetCount ();
3 SectionPtr word_section=word_sections - & gt; The Item (num - 1);
4 PageSetupPtr page_setup=word_section - & gt; GetPageSetup ();
5 TextColumnsPtr text_cols=page_setup & gt; GetTextColumns ();
6 text_cols - & gt; PutEvenlySpaced (0);
7 text_cols - & gt; Add (COleVariant (col_width), COleVariant (0) (long), COleVariant ((long), false));
Code, this is others why and I don't like, I will find out his rewriting, prompt function does not accept the three parameters

CodePudding user response:

This should be accomplished is the use of COM components, have difficulty in pure c + + to complete, so help you removed,

CodePudding user response:

//set the direction and margins for the page
If (oPageSetup get_Orientation ()==0)//if is set to horizontal, vertical longitudinal wdOrientPortrait=0, transverse wdOrientLandscape=1
{
OPageSetup. Put_Orientation (1);//lateral
//set up and down or so variable pitch, the unit twips, the following parameters Settings page margins is "moderate"
OPageSetup. Put_TopMargin (float) (72); In the condition of moderate//72=2.54 cm, when the default 90=3.17 cm; 10 material 0.35 cm
OPageSetup. Put_BottomMargin (float) (72); In the condition of moderate//72=2.54 cm, when the default 90=3.17 cm; 10 material 0.35 cm
OPageSetup. Put_LeftMargin (54 (float));//moderate 54=1.9 cm, by default, 72=2.54 cm
OPageSetup. Put_RightMargin (54 (float));//moderate 54=1.9 cm, by default, 72=2.54 cm
//set to horizontal A3, 420 * 297 * 2.835=1190.7 2.835=842
OPageSetup. Put_PageHeight (float) (842);
OPageSetup. Put_PageWidth (float) (1190.7);
//lpDispatch=oPageSetup get_TextColumns ();

/* SectionsPtr word_sections=docx_active. Get_Sections ();
Long num=word_sections - & gt; Get_Count ();
SectionPtr word_section=word_sections - & gt; The Item (num - 1);
PageSetupPtr page_setup=word_section - & gt; Get_PageSetup (); */
TextColumnsPtr text_cols=oPageSetup. Get_TextColumns ();
Text_cols - & gt; Put_EvenlySpaced (COleVariant (TRUE));
Text_cols - & gt; Add (COleVariant (2) (long), COleVariant (0) (long), COleVariant ((long), false));
//oPageSetup put_TextColumns ((LPDISPATCH), 2);
}




The error C2440: "& lt; The function - style - cast>" : from "int" into "COleVariant" no constructor can accept source type, unclear or constructor overloads decisions
The error C2660: "TextColumns: : Add" : function does not accept three parameters
This is the error code

CodePudding user response:

Related to version,

CodePudding user response:

Is that word version, I am word2003

CodePudding user response:

Ha ha, set a success, too simple, thank you all for the great god, although no one reply

CodePudding user response:

Start recording macros in the Word2003, manual, complete the required function end record macros, press Alt + F11 key, check just record macro corresponding VBA code,
  • Related