![]() |
Open Word Document and Accept Track Changes - Partial Solution
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 |
Open Word Document and Accept Track Changes - Partial Solution
I am having a problem with a similar stmt (my query on this forum is
slightly older -- 1 NOV 7:09AM; the Subject is == Running Macro "Logged Off" & Copy/Paste from WORD .rtf into EXCEL .xls Two changes in my posted code: my file open stmt is now 'Set objDoc = objWord.Documents.Open ("C:\Test\T and A.rtf")'; and I deleted the next stmt 'objDoc.Activate'. When my machine is "logged on", my code works as intended. However, when "logged off" our network, my code stops processing at my revised 'Set objDoc = ...' stmt. And I have about 100 lines of EXCEL VBA code that is processed before it reaches that point. Any ideas? JingleRock |
All times are GMT +1. The time now is 11:50 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com