Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Word Auto: Merging Cells in table
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01414868
Message ID:
01415145
Vues:
47
>Hi all,
>
>Doing some Word automation: example on pg 94 in MSFT Office Automation with VFP says there are 2 ways to merge cells in a table. I got the first one working with this code:
>
>
>
>* see Pg 94 in MS Office Automation for merging; will use the method getting a reference to the first
>* cell, then the 3rd cell and then invoking .Merge() passing the second cell to merge with
>
>STORE loRow.Cells(1) TO loCell_1
>STORE loRow.Cells(3) TO loCell_3
>
>* merge the cells
>loCell_1.Merge(loCell_3)
>
>
>
>but could not get the "2nd method" to work i.e. I did not know how to create an object reference to a range of cells (e.g. cells 1 to 3 above). This was the code that was in the book but it did not explain how to get "oCells"
>
>
>
>oCells.Merge()
>
>
>
>Thanks,
>Albert

Second method is suitable when, say, cells are selected, or you want to merge all cells in the table:
oWord.Selection.Cells.Merge()    && preselected cells
*or
with oWord.ActiveDocument
    .Range(.Tables(1).Cell(1,2).Range.Start, .Tables(1).Cell(1,3).Range.End).Cells.merge
endwith
*or
oWord.Activedocument.Table(2).Cells.Merge()
Other than that, be carefull introducing object references to the pieces of the document. In most cases you can do it with single oWord object reference, like:
with oWord.ActiveDocument.Tables(2).Range
       .Cells(1).Merge(.Cells(3))
endwith
Otherwise if you do not want Office applications remain sitting hidden after you close your application, then you need to release all objects properly, and in the proper sequence from child to parent.

Good Luck
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform