nebbish
2006-03-01 04:54:27 UTC
i'm using VB6 example code from microsoft that produces a standard exe
project which connects to an mdb file to get the data and connects to an xls
file to write the data (at the end of this post i've included the url of the
microsoft article that has the code).
now the example works just fine as is.....BUT....when i try to put the code
in a VBA project (i'm using VBA from within Access) i get an 0x80040e09 error
when ever i call .AddNew on the recordset that was opened against the excel
file.
First my question - why doesn't the Jet Excel engine work differently in VBA
compared to VB6 - and secondly is there *ANY* other way to perform recordset
updates (in VBA) when the recordset is opened against an excel file.
thanks in advance for any thoughts, answers, comments...
Now some explanation of what i did:
i created a new Module (left it called 'Module1') and pasted ALL the code
from Form1.frm.
the sample code basically consists of 5 button click handlers and a
form_load handler. form_load only initialized some global variables, so when
i transfered the code into VBA i removed that function and turned the global
variables into global constants.
then i added another global constant called MyAppPath which i used to
simulate "App.Path" which is used all over in the example code - i simple
initialized this new constant with the path where i unzipped the example code.
lastly i just commented out all the calls to ShellExecute - they only bring
up the results anyway.
then to run the code, since it is VBA, i just put the cursor in the handler
named 'cmdSample3_Click' and hit F5
i get the error on the following line:
. . .
Do While Not (oProdRS.EOF)
*** oRS.AddNew
oRS.Fields(0) = oProdRS.Fields("ProductName").Value
. . .
the example code came from the following microsoft article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;278973
which is entitled "ExcelADO demonstrates how to use ADO to read and write
data in Excel workbooks" - just in case the link doesn't work googling a
couple of words from the title should work.
thanks again,
nebbish
project which connects to an mdb file to get the data and connects to an xls
file to write the data (at the end of this post i've included the url of the
microsoft article that has the code).
now the example works just fine as is.....BUT....when i try to put the code
in a VBA project (i'm using VBA from within Access) i get an 0x80040e09 error
when ever i call .AddNew on the recordset that was opened against the excel
file.
First my question - why doesn't the Jet Excel engine work differently in VBA
compared to VB6 - and secondly is there *ANY* other way to perform recordset
updates (in VBA) when the recordset is opened against an excel file.
thanks in advance for any thoughts, answers, comments...
Now some explanation of what i did:
i created a new Module (left it called 'Module1') and pasted ALL the code
from Form1.frm.
the sample code basically consists of 5 button click handlers and a
form_load handler. form_load only initialized some global variables, so when
i transfered the code into VBA i removed that function and turned the global
variables into global constants.
then i added another global constant called MyAppPath which i used to
simulate "App.Path" which is used all over in the example code - i simple
initialized this new constant with the path where i unzipped the example code.
lastly i just commented out all the calls to ShellExecute - they only bring
up the results anyway.
then to run the code, since it is VBA, i just put the cursor in the handler
named 'cmdSample3_Click' and hit F5
i get the error on the following line:
. . .
Do While Not (oProdRS.EOF)
*** oRS.AddNew
oRS.Fields(0) = oProdRS.Fields("ProductName").Value
. . .
the example code came from the following microsoft article:
http://support.microsoft.com/default.aspx?scid=kb;en-us;278973
which is entitled "ExcelADO demonstrates how to use ADO to read and write
data in Excel workbooks" - just in case the link doesn't work googling a
couple of words from the title should work.
thanks again,
nebbish