View Single Post
 
Old 06-24-2021, 11:14 PM
soroush.kalantari soroush.kalantari is offline Windows 10 Office 2016
Competent Performer
 
Join Date: Jun 2021
Posts: 124
soroush.kalantari is on a distinguished road
Default Is there a way to stop macro modifications from undoing when Updating Word Linked Tables?

I have written a macro to optimize the routine modifications (changing font, row height, size, etc.) I always make for the tables linked from Excel to Word. Now the problem is that when I update the tables (via right click/update Link), all the macro modifications are undone. Is there a remedy for this problem? (Note: the same doesn’t happen if the modifications are made manually (without macro). I use Word 2016. I have found this problem is not specific to my macro and is the case for every macro running on linked Word tables. See the following simple example which just autofits a table and determines its height). I have also posted this question on SuperUser and Quora. (Cross posting for not getting a satisfactory answer)

Sub autofit()

' autofit Macro

Selection.Tables(1).AutoFitBehavior (wdAutoFitWindow)
Selection.Tables(1).Rows.Height = CentimetersToPoints(0.01)

End Sub
Reply With Quote