Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Insert Row into MS Word Table
Hi All,
I am building the following code that should update large numbers of identical documents. It opens up all the word documents within the directory where the excel sheet is. It then modifies each doc 1 by 1. The parts I am stuck on are (1) De-activating track changes -- ActiveDocument.TrackRevisions = False ("Object doesn't support this property or method") (2) Insert a row at the bottom of the first table - this is the bit that does that:- oAppWD.ActiveDocument.Tables(1).Rows.Last.Select Selection.InsertRowsBelow Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=2 Selection.TypeText Text:= _ "V4.0 Construct Tollgate Baseline - Same as Previous Version" Any ideas on how I might get this to work? Sub UpdateWordData() Dim oAppWD As Object Dim strPath As String Dim FileName As String strPath = ActiveWorkbook.Path Set fs = Application.FileSearch With fs .LookIn = strPath .SearchSubFolders = False .FileName = ".doc" If .Execute() 0 Then Application.ScreenUpdating = False Set oAppWD = CreateObject("Word.Application") For i = 1 To .FoundFiles.Count oAppWD.Documents.Open FileName:=.FoundFiles(i) 'oAppWD.Visible = False FileName = Dir(.FoundFiles(i)) 'With oAppWD.ActiveDocument.Tables(1) oAppWD.WordBasic.AcceptAllChangesInDoc ActiveDocument.TrackRevisions = False With oAppWD.ActiveDocument.Tables(1) 'Table 1 .Rows(1).Cells(2).Range.Text = "V4.0" End With oAppWD.ActiveDocument.Tables(1).Rows.Last.Select Selection.InsertRowsBelow Selection.MoveRight Unit:=wdCharacter, Count:=1 Selection.MoveLeft Unit:=wdCharacter, Count:=2 Selection.TypeText Text:= _ "V4.0 Construct Tollgate Baseline - Same as Previous Version" oAppWD.Documents.Save oAppWD.Documents.Close Next i oAppWD.Application.Quit Set oAppWD = Nothing Application.ScreenUpdating = True End If End With End Sub |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
how can i get insert table and draw table icon in my tool bar? | Excel Discussion (Misc queries) | |||
Link table from excel to word using word VBA | Excel Discussion (Misc queries) | |||
Insert rows in linked table that are added to secondary table | Excel Discussion (Misc queries) | |||
=SUM Then insert word. | Excel Worksheet Functions | |||
Excel VBA - Insert Word Table problem | Excel Programming |