A
Andibevan
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
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