[Solved] Merging cells in VBA

Java, C++, C#, Delphi, ??? - Using the UNO bridges

[Solved] Merging cells in VBA

Postby TownTalk » Mon Dec 10, 2012 5:30 pm

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
TownTalk
 
Posts: 9
Joined: Mon Dec 10, 2012 5:19 pm

Re: Merging cells in VBA

Postby FJCC » Mon Dec 10, 2012 6:50 pm

In OOBasic it could be done like this:
Code: Select all   Expand viewCollapse view
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)
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7680
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Merging cells in VBA

Postby TownTalk » Mon Dec 10, 2012 7:04 pm

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
TownTalk
 
Posts: 9
Joined: Mon Dec 10, 2012 5:19 pm


Return to External Programs

Who is online

Users browsing this forum: No registered users and 2 guests