Solved

How to delete rows in Excel document using TExcelApplication object

Posted on 2003-10-27
2
488 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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi prevent click fast 2 214
Virtuailstring tree add node to another virtuailstring tree list 4 115
Downloading email attachments 2 73
Create a path if not exists 7 76
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 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