Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 08-29-2017, 08:42 AM
blbrand165 blbrand165 is offline Help with CompareDocuments / datatype DOCUMENT Windows 7 64bit Help with CompareDocuments / datatype DOCUMENT Office 2016
Novice
Help with CompareDocuments / datatype DOCUMENT
 
Join Date: Aug 2017
Posts: 1
blbrand165 is on a distinguished road
Default Help with CompareDocuments / datatype DOCUMENT

I'm at wits end and hoping some experts here can help. Basically, I'm trying to create a macro to compare two saved documents. I need to use a macro because I want to be able to specify certain parameters in different ways, automatically through the macro.



The only way I've been able to get it to work is by OPENING both docs, then running Application.CompareDocuments, then closing both docs.

Does anyone know how to do this without opening both docs to be compared? This seems like an unnecessary step to me.

More specifically, I'm trying to execute the following command in VBA:

Set doc3 = Application.CompareDocuments(doc1, doc2, _
Destination:=wdCompareDestinationNew, _
Granularity:=wdGranularityWordLevel, _
CompareFormatting:=True, _
CompareCaseChanges:=True, _
CompareFields:=False, _
CompareWhiteSpace:=True)


According to the MS website, doc1 and doc2 must be of the data type: DOCUMENT.

The only way I know to get doc1 to be a datatype of DOCUMENT is to do the following:

Set doc1 = Documents.Open(path1)

where path1 is a string "C:\filename.docx"

what I want to do is

Set doc1 = path1 -- but that doesn't work. How can I set doc1 to "C:\filename.docx" without opening that document? Note that I really need to be able to set it to a doc selected in a dialog box.


Here is what is driving me crazy: there is another Method called "Document.Compare" which seems very similar, except that it: 1) compares an open document to a saved document; 2) it appears to have fewer parameters than Compare.Documents (specifically, the one I need); and 3) it uses a STRING instead of a DOCUMENT as the parameter type.

expression . Compare( Name , AuthorName , CompareTarget , DetectFormatChanges , IgnoreAllComparisonWarnings , AddToRecentFiles , RemovePersonalInformation , RemoveDateAndTime )


In this method, NAME is a string.


the CompareDocuments method is defined as:

expression . CompareDocuments( OriginalDocument , RevisedDocument , Destination , Granularity , CompareFormatting , CompareCaseChanges , CompareWhitespace , CompareTables , CompareHeaders , CompareFootnotes , CompareTextboxes , CompareFields , CompareComments , RevisedAuthor , IgnoreAllComparisonWarnings )

and here, OriginalDocument and RevisedDocument must be a datatype of DOCUMENT, not a string. Don't ask me why . . .

sorry for the rambling post, but I am lost on this and have been pulling my hair out for week trying to figure it out. thanks in advance for any help!
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Help with CompareDocuments / datatype DOCUMENT split word document based on bookmarks with each new document title of the bookmark megatronixs Word VBA 9 09-05-2020 02:29 PM
From a docx report document save all images in a cell from the document to a folder censura Word VBA 1 05-13-2017 12:54 AM
Single step Word Styles from Source Document through entire Destination document? xbliss Word 6 08-27-2016 09:36 PM
Adding a link into a word document that when pressed, takes user to a page within the same document yan89 Word 1 04-29-2016 01:54 PM
Vba code to save document as pdf using document property text and rename folder. staicumihai Word VBA 1 12-21-2015 07:39 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 11:21 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