Doug Steele
dbdoug at gmail.com
Sun Jan 23 13:46:22 CST 2011
Hello All:
I am creating an Excel 2003 workbook from Access. I need to apply
standard formatting to each sheet, so I thought I would build a
subroutine to apply the formats as follows (the code has been
abbreviated here).
**********************************************************
In my main procedure:
Dim MySheet as Excel.Worksheet
For i = 0 To myExcelApp.Worksheets.Count - 1
Set MySheet = myExcelApp.Worksheets(i + 1)
FormatSheet (MySheet)
Next i
My formatting sub:
Private Sub FormatSheet(sht as Excel.Worksheet)
sht.Select
Rows(1).Select
With Selection
.Font.Bold = True
.HorizontalAlignment = xlCenter
End With
.... etc etc
End Sub
**************************************************************
Everything works fine if I put the formatting code right in the 'for'
loop, but when I try to run it by calling the format sub from the
loop, I get an 'Object doesnt' support this property or method' error
on the 'FormatSheet(MySheet)' line.
Doug