Hi, @Daniel Zhang-MSFT ,
I am using Microsoft Visual Studio 2019. Actually I have managed to delete the gap and merge two tables, just by writting the Delete() statement twice.
My sample C# codes are shown below.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
void deleteGapText(Word.Document doc, string txt)
{
object missing = System.Reflection.Missing.Value;
doc.Content.Find.ClearFormatting();
object keyword = txt.ToString();
if (doc.Content.Find.Execute(ref keyword, ref missing, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing))
{
var range = doc.Content;
if (range.Find.Execute(txt))
{
range.Expand(Word.WdUnits.wdParagraph); // or change to .wdSentence or .wdLine
range.Delete();
// TH, 04Aug21, to completely merge the two adjacent tables
range.Expand(Word.WdUnits.wdParagraph); // or change to .wdSentence or .wdLine
range.Delete();
// Word.Paragraph para = app.Selection.Range.Paragraphs[1];
// tbl.Rows.WrapAroundText = -1;
}
}
else
{
log_msg(Settings.Default.LogFile, string.Format("deleteGapText(): TableGapText ({0}) cannot be found.", txt));
}
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Anyway, thank you for the help anyway.
I would select to "Accept Answer".
Rgds,
Daniel