Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The following function is designed to open a specified word doc and accept
the track changes but I keep getting an 'object variable or with block variable not set, on the line Set oDoc = oAppWD.Documents.Open(Filename:=sFilePath) Any ideas why? TIA Andi Function fAcceptTrackChanges(sFilePath) As Boolean fAcceptTrackChanges = False Dim oAppWD As Object Set oAppWD = OpenWordObj() Dim SourceFolder As Scripting.Folder, SubFolder As Scripting.Folder Dim oDoc As Object Dim r As Long If Right(sFilePath, 4) = ".doc" Then Set oDoc = oAppWD.Documents.Open(Filename:=sFilePath) oDoc.AcceptAllRevisions oDoc.TrackRevisions = False oAppWD.Documents.Save oAppWD.Documents.Close ' Print result End If Set oAppWD = Nothing Set SourceFolder = Nothing fAcceptTrackChanges = True End Function Function OpenWordObj() As Object Dim m_wrd As Object 'Word.Application Debug.Print "Open Excel" On Error Resume Next Set m_wrd = GetObject(, "Word.Application") If m_wrd Is Nothing Then Set m_wrd = CreateObject("Word.Application") End If If m_wrd Is Nothing Then MsgBox "Can't Create Word Object" 'OpenWord = False Else 'OpenWord = True End If DoEvents ' OpenWord = m_wrd m_wrd.Visible = True OpenWordObj = m_wrd End Function |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Track and Accept changes in Shared and Protected | Excel Discussion (Misc queries) | |||
Track/Accept Changes | Excel Worksheet Functions | |||
How do I automatically accept a solver solution in a macro? | Excel Programming | |||
open a new word document | Excel Discussion (Misc queries) | |||
Open a Word Document | Excel Programming |