Hello.
I have several thousands of word mail-merge documents that i’m not trying to merge using aspose words.
everything works as expected, except one thing.
each document contains the following macro.
what this macro does, is merge the source document into a new one, and the delete empty rows from a table.
(i have some other types of macros that are more complex than this one…).
the problem is, that the macro fails to execute while trying to merge itself into a new document, since it has already been merged by Aspose.
can anyone here think of a creative solution ?
(deleting empty rows using aspose won’t do the trick since thi is only one type of macro, there are a lot of more complex ones. and during the merge process i can’t tell which document has which macro in it)
Sub AutoOpen()
Selection.WholeStory
Application.Run MacroName:=“RTLRUN”
Selection.MoveUp Unit:=wdLine, Count:=1
With ActiveDocument.MailMerge
.Destination = wdSendToNewDocument
.SuppressBlankLines = True
With .DataSource
.FirstRecord = wdDefaultFirstRecord
.LastRecord = wdDefaultLastRecord
End With
.Execute Pause:=False
End With
Selection.WholeStory
Application.Run MacroName:=“RTLRUN”
Selection.MoveUp Unit:=wdLine, Count:=1
Dim TblCnt As Single
Dim MaxTblCnt As Single
TblCnt = 1
y = ActiveDocument.Range.Tables.Count
While TblCnt <= y
CurrTbl = ActiveDocument.Range.Tables(TblCnt)
CurrCell = ActiveDocument.Range.Tables(TblCnt).Cell(CurrTbl.Rows.Count, 1)
While (Len(CurrCell.Text) < 3)
CurrTbl.Rows(CurrTbl.Rows.Count).Delete
CurrTbl = ActiveDocument.Range.Tables(TblCnt)
CurrCell = ActiveDocument.Range.Tables(TblCnt).Cell(CurrTbl.Rows.Count, 1)
Wend
TblCnt = TblCnt + 1
Wend
End Sub