Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-10-2017, 01:07 PM
Thefirstfish` Thefirstfish` is offline Document Comparison Windows 10 Document Comparison Office 2016
Novice
Document Comparison
 
Join Date: Dec 2015
Posts: 11
Thefirstfish` is on a distinguished road
Default Document Comparison

Edit: I figured out an answer to this question after a burst of inspiration.

My aim was to make a macro that duplicates a document, runs some editing macros on the new copy, then compares the original file with the new file. I'm doing it this way because having Track Changes on causes problems for the editing macros.

The working code is:



Code:
Sub Save_Then_Compare()

'Set original document as oDoc
Dim oDoc As Word.Document
Set oDoc = ActiveDocument

'Save original document
ActiveDocument.Save

'Select all text and paste into a new document
ActiveDocument.Range.Select
ActiveDocument.Range.Copy
Documents.Add
Selection.Paste

'Save as docx under a new filename
ActiveDocument.SaveAs2 Filename:="Output.docx", _
        FileFormat:=wdFormatDocumentDefault

'Run editing macros, then save and close the new file
EditMacro1
EditMacro2
ActiveDocument.Save
ActiveDocument.Close
        
'Compare the original and revised files and generate the comparison in oDoc
oDoc.Compare Name:="Output.docx", _
 CompareTarget:=wdCompareTargetCurrent, _
 IgnoreAllComparisonWarnings:=False, _
 Authorname:="Author"

Exit Sub
End Sub
Cheers,

Chris

Last edited by Thefirstfish`; 04-10-2017 at 05:52 PM. Reason: Found a solution
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Comparison (with styles) Macro aarona Word VBA 0 03-03-2017 11:18 PM
Document Comparison Supplier Comparison Scorecard Questions BusinessBuilder Excel 2 08-22-2015 09:17 AM
Document Comparison Complex date comparison/Selection using fields instead of VBA Fields Word 8 06-06-2012 05:13 PM
Saving & reopening comparison MarshallAbrams Word 0 03-29-2012 06:19 AM
Comparison jumps to end MarshallAbrams Word 2 03-21-2012 04:04 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:29 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft