How do I do this in right way? No it doesent work...
VB Code:
  1. Dim xlApp As Excel.Application
  2. Dim xlBook As Object
  3. Dim xlSheet As Object
  4.  
  5.     Set xlApp = CreateObject("Excel.Application")
  6.     Set xlBook = xlApp.Workbooks.Add
  7.     Set xlSheet = xlBook.Worksheets(1)
  8.    
  9. xlApp.ScreenUpdating = False
  10.    
  11.     With xlSheet
  12.         .PageSetup.Orientation = xlLandscape
  13.         .PageSetup.LeftMargin = xlApp.Application.InchesToPoints(0.196850393700787)
  14.         .PageSetup.RightMargin = xlApp.Application.InchesToPoints(0.196850393700787)
  15.         .PageSetup.TopMargin = xlApp.Application.InchesToPoints(0.78740157480315)
  16.         .PageSetup.BottomMargin = xlApp.Application.InchesToPoints(0.78740157480315)
  17.         .Range("A1:P1").Select
  18.         .Selection.MergeCells = True
  19.         .Rows("1:1").RowHeight = 36.75
  20.         .ActiveCell.FormulaR1C1 = "TestHeader"
  21.         .Selection.Font.Size = 14
  22.         .Selection.Font.Bold = True
  23.         .Selection.HorizontalAlignment = xlCenter
  24.         .Selection.VerticalAlignment = xlCenter
  25.         .Range("A2").Select
  26.         .Application.Visible = True
  27.  End With
  28.  
  29.  
  30.     Set xlSheet = Nothing
  31.     Set xlBook = Nothing
  32.     Set xlApp = Nothing