Please help with the following code:
this code starting from (add and format heading) used to print the heading "My Detailed Recommendations" and then printed the text from a textbox in excel into the word doc. All of the paragraphs were printing correctly from their respective textbox in excel, however once I added the code to "add table" above this code, the heading and text from the excel text box are now incorporated into the table, which I don't want; I want the heading and paragraph to just print below the table. Help, I am really stumped!
Code:
'add table
Dim intNoOfRows As Integer
Dim intNoOfColumns As Integer
Dim objRange2
Dim objTable
intNoOfRows = 8
intNoOfColumns = 7
Set objRange2 = wdApp.Selection.Range
wdApp.Selection.Range.tables.Add objRange2, intNoOfRows, intNoOfColumns
Set objTable = wdApp.Selection.Range.tables(1)
objTable.Borders.Enable = True
For i = 1 To intNoOfRows
For j = 1 To intNoOfColumns
objTable.Cell(i, j).Range.text = "Sumit_" & i & j
Next
Next
'add and format heading - "My Detailed Recommendations"
wdApp.Selection.Font.Name = "Calibri"
wdApp.Selection.Font.Size = 13
wdApp.Selection.Font.Bold = True
wdApp.Selection.typetext text:="My Detailed Recommendations"
wdApp.Selection.typeparagraph
'set paragraph to txtDetails text, format and add a blank line
paragraph = UserForm1.txtDetails.text
wdApp.Selection.Font.Name = "Calibri"
wdApp.Selection.Font.Size = 11
wdApp.Selection.Font.Bold = False
this code starting from (add and format heading) used to print the heading "My Detailed Recommendations" and then printed the text from a textbox in excel into the word doc. All of the paragraphs were printing correctly from their respective textbox in excel, however once I added the code to "add table" above this code, the heading and text from the excel text box are now incorporated into the table, which I don't want; I want the heading and paragraph to just print below the table. Help, I am really stumped!
Last edited by a moderator: