Rahul Agarwal
New Member
I am copying a set of data from various excel files into a Word Document at specified bookmarks. If any file is absent during run then at that specified bookmark next line character is printing which is creating space between the data. How to remove this blank space if content for that bookmark is not present. This time I'm using the below mentioned code. In the attached image under "HELP NEEDED" section there is a lots of gap between Simulation and Performance as there is a bookmark between them and its data is not present with us. It is desired to omit this blank space due to unused bookmarks.
Code:
ActiveDocument.Bookmarks(BM_name).Select
sheet.Sheets("Weekly Update").Range(Cell_name).Borders.LineStyle = xlNone
s = Replace(Trim(sheet.Sheets("Weekly Update").Range(Cell_name).Value), Chr(10) & Chr(10), "")
Selection.TypeText Text:=s