I have a word document with some tables. Now the tables are actually copied from excel. The formatting of the tables in word is different from that in excel.
I need to develop a macro which can access the tables in excel and update the same in word, without changing the formatting of the table in word.
The new table from excel may have a few rows more or a few rows less that the old table in word which it should replace.
I have developed a code which manages to bring in the new tables from excel, but the formatting is an issue.
What I have done is marked the tables in word as bookmarks. I have an excel sheet where the bookmark is associated with a specific range (passed through 'range' variable ) from a specific sheet(passed through Sheet_name variable) in another excel tab where the tables are present.
The code is given below. Please suggest a way to achieve the desired outcome.
For Each bmk In ActiveDocument.Bookmarks
vBookmarks(j) = bmk.Name
j = j + 1
Next bmk
For x = 0 To j - 1
table_num = Val(Right$(vBookmarks(x), 2))
MsgBox (table_num)
Selection.GoTo What:=wdGoToBookmark, Name:=vBookmarks(x)
Selection.Cut
objWbk.Worksheets(Sheet_name).Range(range).Copy
Selection.PasteExcelTable False, True, True
'now reinstate the bookmark
objDoc.Bookmarks.Add Name:=vBookmarks(x), Range:=ActiveDocument.Tables(table_num).Range
Next x
Thanks in advance!!!
Bookmarks