Page 1 of 1

[Solved] Merging cells in VBA

Posted: Mon Dec 10, 2012 5:30 pm
by TownTalk
I'm writing an MS Access class module to export data into OpenOffice calc. Can someone give me a pointer please for how to merge cells in VBA. I've been searching for a code example and I can't find anything.

The OO Developers Guide talks about using com.sun.star.util.XMergeable but I cannot find anything which shows me how to use it.

Thanks

Re: Merging cells in VBA

Posted: Mon Dec 10, 2012 6:50 pm
by FJCC
In OOBasic it could be done like this:

Code: Select all

oSheets = ThisComponent.Sheets 'This line would need to be different in VBA since ThisComponent is specific to  OOBasic
oSheet1 = oSheets.getByName("Sheet1")
oCells = oSheet1.getCellrangeByname("A3:C3")
oCells.merge(True)

Re: Merging cells in VBA

Posted: Mon Dec 10, 2012 7:04 pm
by TownTalk
I was looking for something too complicated. I already had a range object instantiated. So all I had to do was the .Merge True

It works a treat. Thanks for your help.