ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   ADD, RENAME AND DELETE COLUMNS using ADO (https://www.excelbanter.com/excel-programming/340255-add-rename-delete-columns-using-ado.html)

Paramasivan

ADD, RENAME AND DELETE COLUMNS using ADO
 
Hi All,

I would like to ADD, RENAME and DELETE COLUMNS In Excel using ADO.
I am using ADO 2.7, Excel 2002.

I have used the following code for delete column..

conConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;
Data Source=""" & strExcelFileName & """;Extended Properties=""Excel
8.0;HDR=Yes"""
conConnection.Mode = adModeReadWrite
conConnection.Open
strSQL = "ALTER TABLE [" & SheetName & "$] DROP COLUMN [" &
strColumnName & "]"
conConnection.Execute strSQL


Similarly I have used SQL for Adding and renaming columns.

But in all cases I am getting the error -2147467259 Invalid Operation.


Please help me to solve this problem.


Regards,
Paramasivan



All times are GMT +1. The time now is 05:33 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com