Solved

How to delete rows in Excel document using TExcelApplication object

Posted on 2003-10-27
2
501 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Enroll in May's Course of the Month

May’s Course of the Month is now available! Experts Exchange’s Premium Members and Team Accounts have access to a complimentary course each month as part of their membership—an extra way to increase training and boost professional development.

Question has a verified solution.

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

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

731 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