troubleshooting Question

How to Save a Document from File Picker for File Comparison

Avatar of Cook09
Cook09Flag for United States of America asked on
Microsoft OfficeMicrosoft WordMicrosoft Applications
8 Comments3 Solutions691 ViewsLast Modified:
The dilemma: Perform a Comparison of two Documents, and have the user to be able to select the documents via a File Picker, run the comparison and save in a Temp File.  The current code that I have is:

Sub CompareDocuments()
Dim strFile1, strFile2 
Dim strPath1, strPath2 , strPath3 
Dim Doc1 As Document
Dim Doc2 As Document
Dim Doc3 As Document

         ' Where the Documents are saved as a Constants
    Const Path1 As String = "C:\Documents and Settings\My Account\My Documents\Temp\Doc1.docx"
    Const Path2 As String = "C:\Documents and Settings\My Account\My Documents\Temp\Doc2.docx"
    Const Path3 As String = "C:\Documents and Settings\My Account\My Documents\Temp\Doc3.docx"

      With Application.FileDialog(msoFileDialogFilePicker)
      .Title = "Select Original Document For Comparison"
      .Show
      'Provides the path and filename
   strPath1 = .SelectedItems(1)             
  Documents.Open FileName:=strPath1, ReadOnly:=False, Visible:=True
     Set strPath1 = ActiveDocument
    strPath1 = Doc1
     Set Doc1 = ActiveDocument
     Debug.Print Doc1
 '   ==>   Doc1.SaveAs Path1, wdFormatDocumentDefault
End With 

              'Select Revised File 
     With Application.FileDialog(msoFileDialogFilePicker)
      .Title = "Select Revised File For Comparison"
      .Show
      'Provides the path and filename
   strPath2 = .SelectedItems(1)             
  Documents.Open FileName:=strPath2, ReadOnly:=False, Visible:=True
             'Provides just the Document Name
     Set strPath2 = ActiveDocument
     Set Doc2 = ActiveDocument
     Debug.Print Doc2
 '   ==>   Doc2.SaveAs Path2, wdFormatDocumentDefault
End With 

    Set Doc3 = Application.CompareDocuments(doc1, doc2, _
     Destination:=wdCompareDestinationNew, _
     Granularity:=wdGranularityWordLevel, _
     CompareFormatting:=True, _
     CompareCaseChanges:=True, _
     CompareWhiteSpace:=True)
    
    Doc3.SaveAs2 Path3, wdFormatDocumentDefault

End With

I don't understand why it won't save in the Temp Directory. I've tried several diferent ways of doing this, as can be seen between 1&2. Any Ideas??
ASKER CERTIFIED SOLUTION
PandaPants

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 3 Answers and 8 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 3 Answers and 8 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros