Solved

How to delete rows in Excel document using TExcelApplication object

Posted on 2003-10-27
2
486 Views
Last Modified: 2010-04-05
LocalFileName := 'C:\temp\ExcelDummy.xls';
ExcelApp := TExcelApplication.Create(self);
try
    ExcelApp.Connect;
    ExcelApp.WorkBooks.Open(LocalFileName,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,
                           EmptyParam,0);
    WorkBk := ExcelApp.WorkBooks.Item[1];
    WorkSheet := WorkBk.WorkSheets.Get_Item(1) as _WorkSheet;
    //I need to delete rows 3, 6, 8 in this worksheet. How do I do that??
   
end;
0
Comment
Question by:kiranmahale
2 Comments
 
LVL 11

Accepted Solution

by:
robert_marquardt earned 100 total points
ID: 9631586
The easiest way is to record a macro in Excel and have a look at the macro source.
That should give you enough hints.
0
 
LVL 1

Author Comment

by:kiranmahale
ID: 9657388
Here is the correct code

WorkSheet.Range['A3', 'A3'].EntireRow.Delete(xlUp);
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Both in life and business – not all partnerships are created equal. As the demand for cloud services increases, so do the number of self-proclaimed cloud partners. Asking the right questions up front in the partnership, will enable both parties …
As a trusted technology advisor to your customers you are likely getting the daily question of, ‘should I put this in the cloud?’ As customer demands for cloud services increases, companies will see a shift from traditional buying patterns to new…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now