View Single Post
 
Old 04-28-2015, 03:39 AM
eibst eibst is offline Windows 7 64bit Office 2010 64bit
Novice
 
Join Date: Apr 2015
Posts: 1
eibst is on a distinguished road
Default automate macro for merged document (after merge)

Hi Community!

I got a problem. I'm printing a document from our companies crm with mailmerge. Now the problem is that objects have different attributes (different size) and so sometimes the table gehts filled nearly entirely sometimes its nearly empty ! So I looked for a makro to clean the table and found one working for me :

Code:
  Dim myTable As Table
Dim myRow As Row
Dim myCell As Cell
Dim myRange As Range
Dim IsEmpty As Boolean

For Each myTable In ActiveDocument.Tables
For Each myRow In myTable.Rows
IsEmpty = True
For Each myCell In myRow.Cells
Set myRange = myCell.Range
myRange.MoveEnd Unit:=wdCharacter, Count:=-1
If myRange.Text <> "" Then IsEmpty = False
Next myCell
If IsEmpty Then myRow.Delete
Next myRow
Next myTable
The thing is I want it to run automatically on the merged document which does unfortunately not work with autoOpen(), AutoExec() and so on.
Is there any possibilty that it automatically will be executed on the merged document!

I'm looking forward to your answers

regards
Stefan

PS: Sorry for my bad english
Reply With Quote