Hello All

I am automating the "magazine run" process for a Classic Car club, this involves creating renewal letters in which I include in the letter all the cars that each member owns. I do this via a "catalog" mail merge in word which I control through a Perl script. Adding the cars into a table in this method creates a small one-line table for each car added in the mail merge. When finished, I need to run a "TableJoiner" macro so that all of these individual tables are joined up into one. I found this macro on the internet from a very helpful tutorial on the "catalog" mail merge, it works superbly and it looks like this:

Sub TableJoiner() Application.ScreenUpdating = False Dim oPara As Paragraph For Each oPara In ActiveDocument.Paragraphs With oPara.Range If .Information(wdWithInTable) = True Then With .Next If .Information(wdWithInTable) = False Then If .Text = vbCr Then .Delete End If End With End If End With Next Application.ScreenUpdating = True End Sub

I want to turn this into Perl OLE script so that I can run it on any PC without installing the macro into MS-Word first. Can anyone help me with this please? I have got as far as this:

foreach my $oPara (%{$Word->ActiveDocument->Paragraphs}) { if ($oPara->Range->Information(wdWithInTable)) { if ($oPara->Next->Information(wdWithInTable) eq False) { if ($oPara->Next->Text eq "\r") #vbCr { logoutput("Deleting Line\n"); $oPara->Range->Next->Delete; } } } }

I did start the foreach loop with:

foreach my $oPara ($Word->ActiveDocument->Paragraphs)

But I thought I needed to 'persuade' perl that it was a hash. Any help you can give me would be much appreciated.

Thanks.


In reply to MS-Word OLE and Joining Tables by BrianP6

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.