Solved

Using Delphi to control Excel:How to merge cells?

Posted on 2002-05-17
6
4,744 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
[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
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 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