P
par_60056
I am running Excel 2000 on XP. I have scripts that pull data from a
database and turn them into a number of reports. Each report is
supposed to have our logo and the client's logo. I have the logos on
a sheet in the excel book.
After each sheet is formatted I call a routine to put the logos on.
(see code below)
A single run of formatting creates something in the neighborhood of
160 sheets in 47 books. If I remove adding the logos everything works
fine. Infact I reran the formating so many times that I was opening
"Book 423" withought error. If the adding logos in included the
process gets through about 35 sheets and then I get an error on a line
that says "cannot set the PrintTitleColumns field" and points to the
line :"ActiveSheet.PageSetup.PrintTitleColumns = """ Obviousely this
line is NOT the problem.
Here is how I am adding the logos. Is there a better way? Am I
missing something in here?
Sub addLogo(lastcol As Integer)
Dim left As Integer
Dim top As Integer
Dim height As Integer
Dim width As Integer
Dim hscale As Double
Dim vscale As Double
Dim fscale As Double
Sheets("Logos").Shapes("MyLogo").Copy
With Range(Cells(1, lastcol - 2), Cells(4, lastcol))
left = .left
top = .top
height = .height
width = .width
End With
Range(Cells(1, lastcol - 2), Cells(4, lastcol)).PasteSpecial
Selection.Name = "MyLogo"
vscale = width / ActiveSheet.Shapes.Range("MyLogo").width
hscale = height / ActiveSheet.Shapes.Range("MyLogo").height
fscale = 1
If (hscale <= vscale And hscale < 1) Then
fscale = hscale
ElseIf (vscale < hscale And vscale < 1) Then
fscale = vscale
End If
ActiveSheet.Shapes.Range("MyLogo").ScaleWidth fscale, msoFalse,
msoScaleFromBottomRight
ActiveSheet.Shapes.Range("MyLogo").ScaleHeight fscale, msoFalse,
msoScaleFromTopLeft
ActiveSheet.Shapes.Range("MyLogo").left = (left + width) -
ActiveSheet.Shapes.Range("MyLogo").width - 5
ActiveSheet.Shapes.Range("MyLogo").top = top
Sheets("Logos").Shapes("ClientLogo").Copy
With Range(Cells(1, 1), Cells(4, 3))
left = .left
top = .top
height = .height
width = .width
End With
Range(Cells(1, 1), Cells(4, 3)).PasteSpecial
Selection.Name = "ClientLogo"
vscale = width / ActiveSheet.Shapes.Range("ClientLogo").width
hscale = height / ActiveSheet.Shapes.Range("ClientLogo").height
fscale = 1
If (hscale <= vscale And hscale < 1) Then
fscale = hscale
ElseIf (vscale < hscale And vscale < 1) Then
fscale = vscale
End If
ActiveSheet.Shapes.Range("ClientLogo").ScaleWidth fscale, msoFalse,
msoScaleFromBottomRight
ActiveSheet.Shapes.Range("ClientLogo").ScaleHeight fscale, msoFalse,
msoScaleFromTopLeft
ActiveSheet.Shapes.Range("ClientLogo").left = left + 5
ActiveSheet.Shapes.Range("ClientLogo").top = top
End Sub
database and turn them into a number of reports. Each report is
supposed to have our logo and the client's logo. I have the logos on
a sheet in the excel book.
After each sheet is formatted I call a routine to put the logos on.
(see code below)
A single run of formatting creates something in the neighborhood of
160 sheets in 47 books. If I remove adding the logos everything works
fine. Infact I reran the formating so many times that I was opening
"Book 423" withought error. If the adding logos in included the
process gets through about 35 sheets and then I get an error on a line
that says "cannot set the PrintTitleColumns field" and points to the
line :"ActiveSheet.PageSetup.PrintTitleColumns = """ Obviousely this
line is NOT the problem.
Here is how I am adding the logos. Is there a better way? Am I
missing something in here?
Sub addLogo(lastcol As Integer)
Dim left As Integer
Dim top As Integer
Dim height As Integer
Dim width As Integer
Dim hscale As Double
Dim vscale As Double
Dim fscale As Double
Sheets("Logos").Shapes("MyLogo").Copy
With Range(Cells(1, lastcol - 2), Cells(4, lastcol))
left = .left
top = .top
height = .height
width = .width
End With
Range(Cells(1, lastcol - 2), Cells(4, lastcol)).PasteSpecial
Selection.Name = "MyLogo"
vscale = width / ActiveSheet.Shapes.Range("MyLogo").width
hscale = height / ActiveSheet.Shapes.Range("MyLogo").height
fscale = 1
If (hscale <= vscale And hscale < 1) Then
fscale = hscale
ElseIf (vscale < hscale And vscale < 1) Then
fscale = vscale
End If
ActiveSheet.Shapes.Range("MyLogo").ScaleWidth fscale, msoFalse,
msoScaleFromBottomRight
ActiveSheet.Shapes.Range("MyLogo").ScaleHeight fscale, msoFalse,
msoScaleFromTopLeft
ActiveSheet.Shapes.Range("MyLogo").left = (left + width) -
ActiveSheet.Shapes.Range("MyLogo").width - 5
ActiveSheet.Shapes.Range("MyLogo").top = top
Sheets("Logos").Shapes("ClientLogo").Copy
With Range(Cells(1, 1), Cells(4, 3))
left = .left
top = .top
height = .height
width = .width
End With
Range(Cells(1, 1), Cells(4, 3)).PasteSpecial
Selection.Name = "ClientLogo"
vscale = width / ActiveSheet.Shapes.Range("ClientLogo").width
hscale = height / ActiveSheet.Shapes.Range("ClientLogo").height
fscale = 1
If (hscale <= vscale And hscale < 1) Then
fscale = hscale
ElseIf (vscale < hscale And vscale < 1) Then
fscale = vscale
End If
ActiveSheet.Shapes.Range("ClientLogo").ScaleWidth fscale, msoFalse,
msoScaleFromBottomRight
ActiveSheet.Shapes.Range("ClientLogo").ScaleHeight fscale, msoFalse,
msoScaleFromTopLeft
ActiveSheet.Shapes.Range("ClientLogo").left = left + 5
ActiveSheet.Shapes.Range("ClientLogo").top = top
End Sub