[Solved] Merging cells in VBA

Java, C++, C#, Delphi... - Using the UNO bridges
Post Reply
TownTalk
Posts: 9
Joined: Mon Dec 10, 2012 5:19 pm

[Solved] Merging cells in VBA

Post 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
Last edited by RoryOF on Mon Dec 10, 2012 7:28 pm, edited 2 times in total.
Reason: Added green tick
OpenOffice 3.4 on Windows XP
FJCC
Moderator
Posts: 9248
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Merging cells in VBA

Post 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)
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
TownTalk
Posts: 9
Joined: Mon Dec 10, 2012 5:19 pm

Re: Merging cells in VBA

Post 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.
OpenOffice 3.4 on Windows XP
Post Reply