P
Pendragon
This was working and now is not. Going to put in the Excel group as well.
Any ideas are appreciated. The error is 91 Object variable or With variable
not set.
Set rs = db.OpenRecordset(sSQL)
stCell = "B2"
rs.MoveFirst
With objWkbk
.Sheets("Sheet1").Select
.Sheets("Sheet1").Activate
.Sheets("Sheet1").Name = stSheetName
icolumn = 0
.ActiveSheet.Range("A1").Activate
.ActiveSheet.Range("A1").Value = "Officials Assignments - " &
Format(MyDate, "dddd, mmmm dd, yyyy")
.ActiveSheet.Range("A1").Font.Bold = True
Do While Not rs.EOF
icolumn = icolumn + 1
CName = rs("CourtName")
With .ActiveSheet
.Range(stCell).Select
.Range(stCell).Activate
End With
With .ActiveSheet
ActiveCell.Offset(0, icolumn).Select ***FAILS HERE***
ActiveCell.Offset(0, icolumn).Activate
With ActiveCell
.Value = CName
.HorizontalAlignment = xlcenter
.Font.Bold = True
End With
......
I've matched up all the WITH - END WITH pairs and double-checked that
everything is defined. I put in a MsgBox to test that the worksheet was
activated and named properly - this was successful. I tried to do the same
thing for the active cell (Activecell.Name) but this generated the same error.
Thanks for any help.
Any ideas are appreciated. The error is 91 Object variable or With variable
not set.
Set rs = db.OpenRecordset(sSQL)
stCell = "B2"
rs.MoveFirst
With objWkbk
.Sheets("Sheet1").Select
.Sheets("Sheet1").Activate
.Sheets("Sheet1").Name = stSheetName
icolumn = 0
.ActiveSheet.Range("A1").Activate
.ActiveSheet.Range("A1").Value = "Officials Assignments - " &
Format(MyDate, "dddd, mmmm dd, yyyy")
.ActiveSheet.Range("A1").Font.Bold = True
Do While Not rs.EOF
icolumn = icolumn + 1
CName = rs("CourtName")
With .ActiveSheet
.Range(stCell).Select
.Range(stCell).Activate
End With
With .ActiveSheet
ActiveCell.Offset(0, icolumn).Select ***FAILS HERE***
ActiveCell.Offset(0, icolumn).Activate
With ActiveCell
.Value = CName
.HorizontalAlignment = xlcenter
.Font.Bold = True
End With
......
I've matched up all the WITH - END WITH pairs and double-checked that
everything is defined. I put in a MsgBox to test that the worksheet was
activated and named properly - this was successful. I tried to do the same
thing for the active cell (Activecell.Name) but this generated the same error.
Thanks for any help.