Solved

Using Delphi to control Excel:How to merge cells?

Posted on 2002-05-17
6
4,594 Views
Last Modified: 2007-12-19
//thanks :)
var
  ExcelApplication1: TExcelApplication;
  ExcelWorksheet1: TExcelWorksheet;
  ExcelWorkbook1: TExcelWorkbook;
begin
  {
  I Created the three objects properly,and i can write
  data into Excel now
  }
  //if i want to merge some cells,[1,2]-[4,5],for example
  ExcelWorkSheet1.Cells.Merge({what should be here?});
  //or use ExcelWorkSheet1.Cells.MergeCells?? or what
end;
0
Comment
Question by:Conwood
6 Comments
 
LVL 11

Expert Comment

by:robert_marquardt
ID: 7016039
You should install the VBA help of Excel.
See if it is on your Office CD.
VBA calls the same COM objects you call from Delphi so the VBA help should give you the info you need.
Record a macro and have a look at the macro source.
0
 
LVL 4

Expert Comment

by:max-hb
ID: 7016073
Hi!
Maybe you shouldlook at
http://www.paragoncorporation.com/papers/articledetail.asp?ArticleID=2

This article gives a (very) brief introduction to Excel programming (using VBA)
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 7016104
hello

  look at these links they will help you for automation excel

Automating Microsoft Excel using delphi
http://www.djpate.freeserve.co.uk/AutoExcl.htm

Microsoft Office 97/Visual Basic Programmer's Guide
http://www.microsoft.com/officedev/articles/Opg/004/004.htm

0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
LVL 2

Expert Comment

by:Tasomia
ID: 7017999
Hi,

Try this:
ExcelApplication1.Range['A1', 'E7'].Mergecells := True;
0
 
LVL 44

Accepted Solution

by:
bruintje earned 200 total points
ID: 7018737
Tasomia is right there

though i would use the worksheet object since excel application is the big container and looking at your code you work with all three objects

app > workbook > worksheet

something like

ExcelWorksheet1.Range['A1','E7'].MergeCells := True;

besides using the VBA help files you can also use the object browser in all office apps

-open the VB Editor in Excel with ALT+F11
-then bring up the object browser with F2
-now you can walk through the objects and their properties + events

:O)Bruintje
0
 
LVL 44

Expert Comment

by:bruintje
ID: 7019360
Tasomia, posted a seperate question for your help here

http://www.experts-exchange.com/delphi/Q.20302187.html
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Suggested Solutions

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…
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 teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
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…

778 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