if you want to copy data from excel worksheet to a table which already exists in the word document. Snapshot below-
Here is the code-
Sub test()
Dim doc As New Word.Application
doc.Visible = True
' TOOL -> REFRENCE-> MICROSOFT WORD
Documents.Open "C:\Documents and Settings\achamanlalko\Desktop\WORD TABLE.doc"
Documents(ActiveDocument.Name).Activate
' 7 is no of columns
'i= 2 because we dont have to take the header row
For i = 2 To 7
' 7 is no of rows
For j = 1 To 3
ActiveDocument.Tables(1).Cell(i, j).Range.Text = Cells(i, j).Value
Next
Next
'if you want to change the font size of table
ActiveDocument.Tables(1).Range.Font.Size = 15
ActiveDocument.Tables(1).Range.Font.Name = "Arial"
'if we add background color to header
ActiveDocument.Tables(1).Rows(1).Range.Shading.BackgroundPatternColorIndex = 5
End Sub
Word Document
Excel Files
Subscribe to:
Post Comments (Atom)
Import data from SQL
Macro to import data from SQL using ADO connection string: Sub Import_data_from_SQL() ' Tools -> References -> Microsoft Active...
-
If you want to add a new menu on mouse right click "Workbook Navigation showing you the list of all open workbooks and worksheets in ea...
-
Macro to Export Range in Json Format Option Explicit Sub export_in_json_format() Dim fs As Object Dim jsonfile Dim rangetoex...
No comments:
Post a Comment