Why would the following code be adding blank pages to my Excel document when I view it in Print Preview? When I comment out the calls in red everything is as it should be. Any ideas? Thanks.
Swi
Code:
With oXLSheet
.Rows("1:1").RowHeight = 48
.Rows("2:2").RowHeight = 26.25
.Rows("3:5").RowHeight = 15.75
.Rows("6:6").RowHeight = 12.75
.Rows("7:26").RowHeight = 18
.Rows("27:74").RowHeight = 12.75
.Rows("75:75").RowHeight = 21
.Rows("76:79").RowHeight = 12.75
.Rows("80:85").RowHeight = 18
.Rows("86:65536").RowHeight = 12.75
.Columns("A:A").ColumnWidth = 15.14
.Columns("B:B").ColumnWidth = 7.14
.Columns("C:C").ColumnWidth = 7.86
.Columns("D:D").ColumnWidth = 10
.Columns("E:E").ColumnWidth = 11.71
.Columns("F:G").ColumnWidth = 13.14
.Columns("H:I").ColumnWidth = 12.86
.Columns("J:J").ColumnWidth = 12
.Columns("K:K").ColumnWidth = 12.29
InsertPictureInRange App.Path & "\ABIS Logo.jpg", .Range("I1:K2")
InsertPictureInRange App.Path & "\ABIS Logo.jpg", .Range("I71:K75")
End With
Sub InsertPictureInRange(PictureFileName As String, TargetCells As Range)
' inserts a picture and resizes it to fit the TargetCells range
Dim p As Object, t As Double, l As Double, w As Double, h As Double
If TypeName(oXLSheet) <> "Worksheet" Then Exit Sub
If Dir(PictureFileName) = "" Then Exit Sub
' import picture
Set p = oXLSheet.Pictures.Insert(PictureFileName)
' determine positions
With TargetCells
t = .Top
l = .Left
w = .Offset(0, .Columns.Count).Left - .Left
h = .Offset(.Rows.Count, 0).Top - .Top
End With
' position picture
With p
.Top = t
.Left = l
.Width = w
.Height = h
End With
Set p = Nothing
End Sub
Swi