c++word 頁面 ,shuizhidao,ruhe分欄,
c++word 頁面 分欄,,這段代碼如何寫啊
CPageSetup oPageSetup = docx_active.get_PageSetup();
// 設定為頁面方向和頁邊距
oPageSetup.put_TextColumns((LPDISPATCH) "2");
簡單點說,如何用c++將生成的word檔案設定成橫向,然后分欄成2欄
【11】設定欄目個數和欄目的寬度
這里一定要注意add函式的邏輯
1 SectionsPtr word_sections = doc->GetSections();
2 long num = word_sections->GetCount();
3 SectionPtr word_section = word_sections->Item(num-1);
4 PageSetupPtr page_setup = word_section->GetPageSetup();
5 TextColumnsPtr text_cols = page_setup>GetTextColumns();
6 text_cols->PutEvenlySpaced(0);
7 text_cols->Add(COleVariant(col_width), COleVariant((long)0), COleVariant((long)false));
這是別人的代碼,我照著改,總是提示函式不接受三個引數
uj5u.com熱心網友回復:
put_textcolumns 值shiduoshaoa?uj5u.com熱心網友回復:
' Macro3 Macro' 宏在 2016/9/3 由 pc 錄制
'
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientPortrait
.TopMargin = CentimetersToPoints(2.54)
.BottomMargin = CentimetersToPoints(2.54)
.LeftMargin = CentimetersToPoints(3.17)
.RightMargin = CentimetersToPoints(3.17)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(1.75)
.PageWidth = CentimetersToPoints(21)
.PageHeight = CentimetersToPoints(29.7)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
.LayoutMode = wdLayoutModeLineGrid
End With
End Sub
Sub Macro2()
'
' Macro2 Macro
' 宏在 2016/9/8 由 pc 錄制
'
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = CentimetersToPoints(3.17)
.BottomMargin = CentimetersToPoints(3.17)
.LeftMargin = CentimetersToPoints(2.54)
.RightMargin = CentimetersToPoints(2.54)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(1.75)
.PageWidth = CentimetersToPoints(42)
.PageHeight = CentimetersToPoints(29.7)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
With .TextColumns
.SetCount NumColumns:=2
.EvenlySpaced = True
End With
.CharsLine = 54
.LayoutMode = wdLayoutModeLineGrid
End With
With ActiveDocument.Styles(wdStyleNormal).Font
If .NameFarEast = .NameAscii Then
.NameAscii = ""
End If
.NameFarEast = ""
End With
With ActiveDocument.PageSetup
.LineNumbering.Active = False
.Orientation = wdOrientLandscape
.TopMargin = CentimetersToPoints(3.17)
.BottomMargin = CentimetersToPoints(3.17)
.LeftMargin = CentimetersToPoints(2.54)
.RightMargin = CentimetersToPoints(2.54)
.Gutter = CentimetersToPoints(0)
.HeaderDistance = CentimetersToPoints(1.5)
.FooterDistance = CentimetersToPoints(1.75)
.PageWidth = CentimetersToPoints(42)
.PageHeight = CentimetersToPoints(29.7)
.FirstPageTray = wdPrinterDefaultBin
.OtherPagesTray = wdPrinterDefaultBin
.SectionStart = wdSectionNewPage
.OddAndEvenPagesHeaderFooter = False
.DifferentFirstPageHeaderFooter = False
.VerticalAlignment = wdAlignVerticalTop
.SuppressEndnotes = False
.MirrorMargins = False
.TwoPagesOnOne = False
.BookFoldPrinting = False
.BookFoldRevPrinting = False
.BookFoldPrintingSheets = 1
.GutterPos = wdGutterPosLeft
With .TextColumns
.SetCount NumColumns:=4
.EvenlySpaced = True
End With
.CharsLine = 26
.LayoutMode = wdLayoutModeLineGrid
End With
End Sub
uj5u.com熱心網友回復:
With .TextColumns.SetCount NumColumns:=4
.EvenlySpaced = True
c++zenmexie
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/126431.html
