I am having problems with counting rows from access in excel. I error out at the "Sheets("Sheet1").Select, I really am not sure what I am doing wrong??? Here is the whole Code that I am using. Any ideas what I can do?
Dim MapFile As String
Dim GlueLogFile As String
'Set path of Glue log
GlueLogPath = "C:\Documents and Settings\test\My Documents\Test Database\Gluelog.xls"
'Open the Gluelog excel file
Set appExcel = GetObject(GlueLogPath)
MsgBox ("Excel File Gluelog.xls Opened")
'Show spreadsheet on screen
appExcel.Application.Visible = True
appExcel.Parent.Windows(1).Visible = True
MsgBox ("Now show excel file")
MsgBox "Starting RowCount"
Sheets("Sheet1").Select
'Find the Next Blank Row
RowCount = 1
Do
RowCount = RowCount + 1
If IsEmpty(Cells(RowCount, 1)) Then
If IsEmpty(Cells(RowCount + 1, 1)) Then
RowCount = RowCount + 1
Exit Do
End If
End If
Loop
MsgBox "RowCount =" + RowCount
'MsgBox ("Writeing data to GlueLog")
Cells(RowCount, 1).Value = "Yes1"
Cells(RowCount, 2).Value = "Yes2"
Cells(RowCount, 3).Value = "Yes3"
Cells(RowCount, 4).Value = "Yes4"
MsgBox ("Writeing to file")
' Turn prompting OFF and save the sheet with original name
appExcel.Application.DisplayAlerts = False
appExcel.Application.Save
'appExcel.Application.DisplayAlerts = True
appExcel.Application.Quit
MsgBox ("Excel Log File Closed")
End Sub
Thanks,
Darkhat01
Dim MapFile As String
Dim GlueLogFile As String
'Set path of Glue log
GlueLogPath = "C:\Documents and Settings\test\My Documents\Test Database\Gluelog.xls"
'Open the Gluelog excel file
Set appExcel = GetObject(GlueLogPath)
MsgBox ("Excel File Gluelog.xls Opened")
'Show spreadsheet on screen
appExcel.Application.Visible = True
appExcel.Parent.Windows(1).Visible = True
MsgBox ("Now show excel file")
MsgBox "Starting RowCount"
Sheets("Sheet1").Select
'Find the Next Blank Row
RowCount = 1
Do
RowCount = RowCount + 1
If IsEmpty(Cells(RowCount, 1)) Then
If IsEmpty(Cells(RowCount + 1, 1)) Then
RowCount = RowCount + 1
Exit Do
End If
End If
Loop
MsgBox "RowCount =" + RowCount
'MsgBox ("Writeing data to GlueLog")
Cells(RowCount, 1).Value = "Yes1"
Cells(RowCount, 2).Value = "Yes2"
Cells(RowCount, 3).Value = "Yes3"
Cells(RowCount, 4).Value = "Yes4"
MsgBox ("Writeing to file")
' Turn prompting OFF and save the sheet with original name
appExcel.Application.DisplayAlerts = False
appExcel.Application.Save
'appExcel.Application.DisplayAlerts = True
appExcel.Application.Quit
MsgBox ("Excel Log File Closed")
End Sub
Thanks,
Darkhat01