からExcelの表すPageSetupクラスのPaperSizeを&オリエンテーションのプロパティを変更することはできません、 コードはエラーなしで実行されますが、エクセル私は用紙サイズやExcelワークシートのシートの向きを変更しようとしているVB.net
で何も変化ここでコード:
Private Sub doCompare()
Dim xlApp As Excel.Application = Nothing
Dim DEs As Excel.Worksheet = Nothing
Dim Rws As Excel.Worksheet = Nothing
Dim ewb As Excel.Workbook = Nothing
XLapp = New Excel.Application
ewb = XLapp.Workbooks.Open("xxxxxxx0.xls")
DEs = ewb.Worksheets("Data Entry")
Rws = ewb.Worksheets("Comparing Results")
'Do something with these worksheets
'Now trying to change default settings. Code copied from Excel macro
xlApp.PrintCommunication = False
Rws.PageSetup.PrintArea = ""
DEs.PageSetup.PrintArea = ""
With Rws.PageSetup
.Orientation = Excel.XlPageOrientation.xlLandscape
.PaperSize = Excel.XlPaperSize.xlPaperA4
.FitToPagesWide = 1 'Fit All Columns to page
End With
xlApp.PrintCommunication = True
End Sub
プリンタドライバが@Maximはあなたのコードを試してみました、それが働いている
ソリューションが見つかりました!最初は 'Rws.PageSetup.PrintArea =" "' xlApp.PrintCommunication = False'の前になければならず、ブック内の** ALL **ワークシートに変更を適用する必要があります –