T
Todd Huttenstine
I was doing a search in Google Groups for code that will write data to a
closed workbook and found this. I am trying to write data to cell A1 of
C:\test.xls. I do not know how to really use databases so this code is very
hard for me. Can anyone please tell me what I need to do to get this to
write lets say "test" to cell A1 of C:\test.xls? This code fails when it
gets to the line: objConn.Execute szSQL, , adCmdText Or
adExecuteNoRecords. I get error Run Time error '-2147217900 (80040e14)':
Automation error. Any help is greatly appreciated.
Thank you
Dim objConn As ADODB.Connection
Dim szConnect As String
Dim szSQL As String
' Create the connection string.
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\test.xls;" & _
"Extended Properties=Excel 8.0;"
' Create the SQL statement.
szSQL = "INSERT INTO <BookLevelName> " & _
"VALUES('Val1', 'Val2', Val3, Val4);"
' Create and open the Connection object.
Set objConn = New ADODB.Connection
objConn.Open szConnect
' Execute the insert statement.
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords
' Close and destroy the Connection object.
objConn.Close
Set objConn = Nothing
Todd Huttenstine
closed workbook and found this. I am trying to write data to cell A1 of
C:\test.xls. I do not know how to really use databases so this code is very
hard for me. Can anyone please tell me what I need to do to get this to
write lets say "test" to cell A1 of C:\test.xls? This code fails when it
gets to the line: objConn.Execute szSQL, , adCmdText Or
adExecuteNoRecords. I get error Run Time error '-2147217900 (80040e14)':
Automation error. Any help is greatly appreciated.
Thank you
Dim objConn As ADODB.Connection
Dim szConnect As String
Dim szSQL As String
' Create the connection string.
szConnect = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:\test.xls;" & _
"Extended Properties=Excel 8.0;"
' Create the SQL statement.
szSQL = "INSERT INTO <BookLevelName> " & _
"VALUES('Val1', 'Val2', Val3, Val4);"
' Create and open the Connection object.
Set objConn = New ADODB.Connection
objConn.Open szConnect
' Execute the insert statement.
objConn.Execute szSQL, , adCmdText Or adExecuteNoRecords
' Close and destroy the Connection object.
objConn.Close
Set objConn = Nothing
Todd Huttenstine