Using VBA in MS Project 2003 I create an Excel sheet and write data to it. After that I want to change SetPrintArea and Orientation of the sheet I created so I wrote
with xlsheet '// Defined being an Excel.Worksheet
For i = 1 To .UsedRange.Columns.Count
.Columns(i).EntireColumn.AutoFit
Next i
txtPrintArea = txtPrintArea & "$" & xlCol.Row '// I created the range to print before
With .PageSetup
.Orientation = xlLandscape
.PrintArea = xlSheet.UsedRange.Address
End With
End With
It crashes at the .Orientation statement. If I comment that out it crashes at the .PrintArea line. My conclusion is it can't set any property of .PageSetup
How can I specify the PrintArea ?