Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Troubleshooting help please

Status
Not open for further replies.
Oct 10, 2003
90
US
Objective: To print out individual sheets from a gradebook.

I have looked around the Internet and cobbled together a script that mostly works. I will post it at the end. While I am still troubleshooting, I am having each individual students grades display. Once I have it working properly, I will remove the Echo comment and have it start printing each invidual page before it cycles to the next student.

I am reading the values from a gradebook (Excel file) that has 5 sheets and changing just one particular value in each formula. After the formulas have been changed, then display all the grades at once. There are 15 lines (students) in the Excel sheet and a 16th line that is averaging the grades for each event as a class.

I have 2 problems that I can't seem to figure out. I can display each student until the count hits 8. Once it hits 8, then its acting as if the task is done and closing the script out. If I change the starting value to 11, the script will continue on. I can't seem to make it do line 9 or 10.

The other minor issue is that line 16, column 1 is empty. So, the Do Until line should stop the script running at that point I would think.

So, what am I doing wrong here?
Thank you

=====================================================

Option Explicit

Dim objExcel, strExcelPath, objSheet, intRow, strStudent, count
Dim strQuiz1, strQuiz2, strQuiz3, strQuiz4
Dim strProj1, strProj2, strProj3, strProj4
Dim strExam1, strExam2, strExam3, strExtra

' Bind to Excel object.
On Error Resume Next
Set objExcel = CreateObject("Excel.Application")
If Err.Number <> 0 Then
On Error GoTo 0
Wscript.Echo "Excel application not found."
Wscript.Quit
End If
On Error GoTo 0

strExcelPath = "c:\GradeSheet.xls"

' Open specified spreadsheet and select the second worksheet.
objExcel.WorkBooks.Open strExcelPath
Set objSheet = objExcel.ActiveWorkbook.Worksheets(2)

' Iterate through the rows of the spreadsheet after the first, until the
' first blank entry in the first column.

intRow = 2
count = intRow

Do While objSheet.Cells(intRow, 1).Value <> ""

objSheet.cells(3,6).Value = "='1301OverallGrades'!A" & count
objSheet.cells(4,6).Value = "='1301OverallGrades'!B" & count
objSheet.cells(5,6).Value = "='1301OverallGrades'!C" & count
objSheet.cells(6,6).Value = "='1301OverallGrades'!D" & count
objSheet.cells(7,6).Value = "='1301OverallGrades'!E" & count
objSheet.cells(8,6).Value = "='Projects'!B" & count
objSheet.cells(9,6).Value = "='Projects'!C" & count
objSheet.cells(10,6).Value = "='Projects'!D" & count
objSheet.cells(11,6).Value = "='Projects'!E" & count
objSheet.cells(12,6).Value = "='1301OverallGrades'!G" & count
objSheet.cells(13,6).Value = "='1301OverallGrades'!H" & count
objSheet.cells(14,6).Value = "='1301OverallGrades'!I" & count
objSheet.cells(15,6).Value = "='Extra Credit'!E" & count

strStudent = objSheet.Cells(3,6).Value
strQuiz1 = objSheet.Cells(4,6).Value
strQuiz2 = objSheet.Cells(5,6).Value
strQuiz3 = objSheet.Cells(6,6).Value
strQuiz4 = objSheet.Cells(7,6).Value
strProj1 = objSheet.Cells(8,6).Value
strProj2 = objSheet.Cells(9,6).Value
strProj3 = objSheet.Cells(10,6).Value
strProj4 = objSheet.Cells(11,6).Value
strExam1 = objSheet.Cells(12,6).Value
strExam2 = objSheet.Cells(13,6).Value
strExam3 = objSheet.Cells(14,6).Value
strExtra = objSheet.Cells(15,6).Value

WScript.Echo "Student : " & vbTab & strStudent & vbCr & _
"Quiz 1 : " & vbTab & strQuiz1 & vbCr & _
"Quiz 2 : " & vbTab & strQuiz2 & vbCr & _
"Quiz 3 : " & vbTab & strQuiz3 & vbCr & _
"Quiz 4 : " & vbTab & strQuiz4 & vbCr & _
"Proj 1 : " & vbTab & strProj1 & vbCr & _
"Proj 2 : " & vbTab & strProj2 & vbCr & _
"Proj 3 : " & vbTab & strProj3 & vbCr & _
"Proj 4 : " & vbTab & strProj4 & vbCr & _
"Exam 1 : " & vbTab & strExam1 & vbCr & _
"Exam 2 : " & vbTab & strExam2 & vbCr & _
"Exam 3 : " & vbTab & strExam3 & vbCr & _
"Extra Credit: " & vbTab & strExtra & vbCr & _
" " & vbTab & vbCr & _
"Count = " & count

intRow = intRow + 1

Loop

' Close workbook and quit Excel.
objExcel.ActiveWorkbook.Close
objExcel.Application.Quit

' Clean up.
Set objExcel = Nothing
Set objSheet = Nothing

Wscript.Echo "Done"

 
From the look of it, you have to move the column in sync with intRow for the consolidated data.
[tt]
objSheet.cells(3,6[blue]+intRow-2[/blue]).Value = "='1301OverallGrades'!A" & count
objSheet.cells(4,6[blue]+intRow-2[/blue]).Value = "='1301OverallGrades'!B" & count
'etc etc...
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top