You have to make sure you select a range first. (There may be other ways to do it, but I use "Range(Cells(row, column), Cells(row, column))")
Then there are 2 ways you can do it using the Merge() and UnMerge() methods or setting the MergeCells Property to True or False >>> from win32com.client import Dispatch >>> ex = Dispatch("Excel.Application") >>> ws = ex.ActiveSheet #or any other way to get the sheet >>> myRange = ws.Range(ws.Cells(1,1),ws.Cells(1,5)) >>> myRange.MergeCells False >>> myRange.MergeCells = True >>> myRange.MergeCells True >>> myRange.MergeCells = False >>> myRange.MergeCells False >>> myRange.Merge() >>> myRange.MergeCells True >>> myRange.UnMerge() >>> myRange.MergeCells False It is a bit different than the VBA Syntax, the way I found out how to do it was by running makepy on the library and then was able to use the code completion to see what was available. (That is how I have learned most things about pywin) Trent Oliphant [EMAIL PROTECTED] wrote: > Hi, > > I hope you can help me. > > I've been using Python with Access and Excel in conjunction with some > power system software for some time now. > > One thing I've been unable to do is merge a defined quantity of cells in > Excel with Python - I can merge entire rows and columns but can't > determine the correct syntax to merge say five cells etc. > > Can anyone help? > > Best Regards, > > Jeff > ------------------------------------------------------------------------ > Jeff Kelliher > Transmission Network Planning, PSDM > ESB National Grid > Tel : +353 01 7026813 > Mailto:[EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> > > > > ******************************************************************* > This E-mail message (including any attachments) is confidential and > intended solely for the use of the individual or entity to whom > it is addressed. If you have received the message in error, please > notify [EMAIL PROTECTED] > > The message has been scanned for viruses. ESB National Grid. > ******************************************************************* > > > ------------------------------------------------------------------------ > > _______________________________________________ > Python-win32 mailing list > Python-win32@python.org > http://mail.python.org/mailman/listinfo/python-win32 > > > ------------------------------------------------------------------------ > > No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.375 / Virus Database: 268.1.1/271 - Release Date: 2/28/2006 _______________________________________________ Python-win32 mailing list Python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32