Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 103
Default 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
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
how can i get insert table and draw table icon in my tool bar? ganesh Excel Discussion (Misc queries) 2 March 25th 08 01:16 AM
Link table from excel to word using word VBA [email protected] Excel Discussion (Misc queries) 7 January 9th 07 05:57 PM
Insert rows in linked table that are added to secondary table Ida LaValley Excel Discussion (Misc queries) 2 August 21st 06 10:52 PM
=SUM Then insert word. iwgunter Excel Worksheet Functions 3 November 1st 04 10:13 AM
Excel VBA - Insert Word Table problem PaulC Excel Programming 1 May 31st 04 01:46 PM


All times are GMT +1. The time now is 10:52 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"