日期:2014-05-18  浏览次数:21095 次

C#处理word横向问题,有谁可以直接给代码设置成横向的,或者我用word宏来解决,怎么转化为C#代码?
Sub Macro2()
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(29.7)
  .PageHeight = CentimetersToPoints(21)
  .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

------解决方案--------------------
不太明白楼主的意思,
word模板好像能解决你的问题,就是.dot结尾的word模板,把模板设置为你要的样式,然后向里面填充内容
------解决方案--------------------
设置为横版
wordApp.Selection.PageSetup.Orientation=word.WdOrientation.wdOrientLandscape;