Just for fun, I am using an example posted on MSDN to copy an entire table's contents into an Excel spreadsheet.
I am using VB6, Excel 2007 and Access 2007.
On this line, "oQryTable.refreshtype = 2 'xlInsertEntireRows = 2", I get the following error:
#438. Object doesn't support this property or method.
I've tried "oQryTable.refreshtype = xlInsertEntireRows" also.--same error.
As I typed this in (from the MSDN example) I DID notice that the 'R' (after the dot) in oQryTable.refresh was not automatically capitalized, so had already expected an error.....
I am using VB6, Excel 2007 and Access 2007.
On this line, "oQryTable.refreshtype = 2 'xlInsertEntireRows = 2", I get the following error:
#438. Object doesn't support this property or method.
I've tried "oQryTable.refreshtype = xlInsertEntireRows" also.--same error.
Code:
Option Explicit
' Add References:
' Microsoft ActiveX DataObjects Library
' Microsoft ActiveX DataObjects Recordset
Dim rs As ADODB.Recordset
Dim cnn As ADODB.Connection
Dim cmd As ADODB.Command
Dim oExcel As Object
Dim oBook As Object
Dim oSheet As Object
Private Sub Command1_Click()
Set oExcel = CreateObject("Excel.Application")
Set oBook = oExcel.Workbooks.Add
Set oSheet = oBook.worksheets(1)
Dim mDB As String
mDB = App.Path & "\quiz.accdb"
Dim oQryTable As Object
Set oQryTable = oSheet.QueryTables.Add( _
"OLEDB;Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" & _
mDB & ";", oSheet.Range("A1"), _
"Select * from quiz")
oQryTable.refreshtype = 2 'xlInsertEntireRows = 2
oQryTable.Refresh False
oBook.saveas App.Path & "\test_book.xlsx"
oExcel.quit
End Sub