Export to Excel not working quite right.

J

jimstruckster

I need some help...

Here is my code to get a SQL table into Excel.

cn3.Open _
"Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source='" & frmRunFile.txtPath.Text & "';Extended
Properties=Excel 8.0;"

strSQL = "SELECT * INTO [Working Copy] FROM filename IN ''
[ODBC;Driver={SQL Server};Server=ITASQL1;Database=database_name ; " & _
"Uid=UserID;" & _
"Pwd=Password];"
cn3.Execute strSQL

I want everything from 'filename' to populate a new tab called
'WorkingCopy'. Every once in a while when the code runs it has the
wrong data all over the new spreadsheet and it messes with data on
other worksheets within the Excel file. Is there a fix for this, or
something I need to change in my code? Thanks

Sorry if this has been posted before, but I couldn't find anything
about it...
 
Top