![]() |
#1
|
|||
|
|||
![]()
I am trying to build a word document from excel. basically the excel table just takes values and transfers them into the word document.
Currently I created part of it but somehow the cursor gets stuck at the first table and the second table is inserted in the first one. The format I am trying to look for is. Text. Table Text Table Ending Text HEre is my code so far. Code:
Option Explicit Sub CreateBasicWordReport() Dim wdApp As Word.Application Dim objRange Dim objDoc Dim Cell Dim NewRange Set wdApp = New Word.Application With wdApp .Visible = True .Activate .Documents.Add With .Selection .ParagraphFormat.Alignment = wdAlignParagraphCenter .BoldRun .Font.Size = 11 .TypeText "Letter to Proceed with Transfer" .TypeParagraph .Font.Size = 11 .TypeText "Determination of Transfer Value and Request for Transfer" .TypeParagraph .TypeParagraph .TypeParagraph .ParagraphFormat.Alignment = wdAlignParagraphLeft End With End With Set objRange = wdApp.ActiveDocument.Range objRange.Collapse Direction:=wdCollapseEnd wdApp.ActiveDocument.Tables.Add objRange, 4, 2 With wdApp.ActiveDocument.Tables(1).Cell(1, 1).Range .Bold = False .Text = "Date" End With With wdApp.ActiveDocument.Tables(1).Cell(2, 1).Range .Bold = False .Text = "Exportin" End With With wdApp.ActiveDocument.Tables(1).Cell(3, 1).Range .Bold = False .Text = "Importing" End With With wdApp.ActiveDocument.Tables(1).Cell(4, 1).Range .Bold = False .Text = "Re" End With With wdApp.ActiveDocument.Tables(1).Cell(1, 2).Range .Bold = False .Text = "Re" End With With wdApp.ActiveDocument.Tables(1).Cell(2, 2).Range .Bold = False .Text = "Re" End With With wdApp.ActiveDocument.Tables(1).Cell(3, 2).Range .Bold = False .Text = "Re" End With With wdApp.ActiveDocument.Tables(1).Cell(4, 2).Range .Bold = False .Text = "Re" End With objRange.Collapse Direction:=wdCollapseEnd wdApp.ActiveDocument.Range.InsertAfter "_____________________________________________________________________________________" wdApp.ActiveDocument.Range.InsertAfter "Part 1" wdApp.ActiveDocument.Bookmarks.Exists ("\EndOfDoc") ' wdApp.ActiveDocument. 'Set NewRange = ActiveDocument.Content 'NewRange.Collapse Direction:=wdCollapseEnd 'wdApp.ActiveDocument.Tables.Add ( 'wdApp.ActiveDocument.Range.Collapse Direction:=wdCollapseEnd 'objRange.Collapse Direction:=wdCollapseEnd 'wdApp.ActiveDocument.Paragraphs.Add.Range.Text = "FGHFHDFg" 'wdApp.ActiveDocument.Tables.Add NewRange, 4, 2 'Set objTable = wdApp.ActiveDocument.Tabl 'objTable.Cell(1, 1).Range.Text = "WOO" 'wdApp.Documents.Add.Tables.Add wdApp.ActiveDocument.Range, 5, End Sub |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
fietstasss | Word VBA | 1 | 01-15-2018 02:05 PM |
How to prevent the text goes down with setting text around the table in MS Word? | tesicg | Word Tables | 1 | 06-07-2016 08:46 AM |
![]() |
jc491 | Word VBA | 8 | 09-30-2015 06:10 AM |
VBA Search Table for Text/Select Text/Insert Hyperlink | sldrellich | Word VBA | 3 | 03-24-2015 01:09 PM |
Convert Text To Table: Separate text at (Other)? | tinfanide | Word VBA | 2 | 01-12-2015 05:26 AM |