Results 1 to 1 of 1

How to merge cells in Word document by VBA code??

Threaded View

  1. #1
    Registered User
    Join Date
    04-06-2004
    Posts
    12

    How to merge cells in Word document by VBA code??

    Hi,
    I am writing a word document from Excel by VBA code, and in the word document there is a table with two rows.

    In the first table row, there are four cells, in the second row there are five cells (after merging cell(1,1) and cell(1,2)). Now I want to merge cell(1,4) and cell(2,5) into one. To do this I suppose I have to select or activate the cells first(maybe not?), but how to?

    I am trying to somehow define a range of cells, but have not succeeded yet..

    This (bold text) seems not to be the correct syntax ??

    Set myTable = wordApp.ActiveDocument.Tables.Add(Range:=wordApp.Selection.Range, NumRows:=2, _
                NumColumns:=5, DefaultTableBehavior:=wdWord9TableBehavior)
    ....
    ...merging cell(2,1) and cell(2,2) and writing to cells..
    ....
    myTable.Range(myTable.cell(1, 4), myTable.cell(2, 5)).Select
    Selection.Cells.Merge
    Someone have a clue??

    Best Regards
    Siri
    Last edited by SiriS; 05-04-2006 at 07:44 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1