I posted another thread about importing but I thought I'd just try to export the data from Access into Excel. It doesn't happen all the time but I am randomly get a 1004 error "Method 'Rows' of object'_Global Failed" It doesn't happen every time and when it doesn't happen all is good with the world. Any help would be super!
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
Set oWb = oApp.Workbooks.Add
Set oWs = oWb.Sheets(1)
oWs.Range("A2").CopyFromRecordset rst
lrow = oWs.Cells(Rows.Count, 2).End(xlUp).Row
cNumRows = lrow - 2
lcol = oWs.Cells(2, Columns.Count).End(xlToLeft).Column
cNumCols = lcol - 1
Set oApp = CreateObject("Excel.Application")
oApp.Visible = True
Set oWb = oApp.Workbooks.Add
Set oWs = oWb.Sheets(1)
oWs.Range("A2").CopyFromRecordset rst
lrow = oWs.Cells(Rows.Count, 2).End(xlUp).Row
cNumRows = lrow - 2
lcol = oWs.Cells(2, Columns.Count).End(xlToLeft).Column
cNumCols = lcol - 1