Compare Documents problem in Word-2007

M

Mahesh_D

Hi All,

In word-2003 and word-2007 Addin for handling compare functionality, i have
added code like this

pseudo code:

Dim dlg as Word.dialog =
Application.Dialogs(WdWordDialog.wdDialogToolsCompareDocuments)
Dim userAction as Long = dlg.Display()

If (userAction <> 0) Then
' User has clicked OK button
' Do some checks and processing on filenames obtained
dlg.Execute()
End if


Affter popping up the dialog box (wdDialogToolsCompareDocuments) in
Word-2003, Only one file input is required and this file is compared with
existing open document.
After user inputs are given, then in variables (dlg.Name - i get the entered
filename) and so further i can do the processing as i got input information.

While in Word-2007 , it takes 2 files as input it doesn't required any
document to be opened.
After user inputs are provided about 2 filenames, then in variables
(dlg.Name - i am not getting any file names ) , and comparison of files is
shown.

So, the problem is after taking user inputs, i am not getting the input
information in Word-2007.


Any pointers will be helpful.


Thanks
Mahesh
 
D

Doug Robbins - Word MVP on news.microsoft.com

You could use the following instead of the Compare Document dialog

Dim fd As FileDialog
Dim comparedocument As String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.Title = "Select the Document that you want to compare with the Active
Document"
.InitialFileName = ""
If .Show = -1 Then
comparedocument = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set fd = Nothing
ActiveDocument.Compare comparedocument


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 
M

Mahesh_D

Thanks Doug.

That is helpful. It works like word-2003 which takes one input.
I think for merging, we can use Activedocument.Merge option.

Any idea, what to be done for word-2007 functionality which takes 2 files as
input
 
D

Doug Robbins - Word MVP on news.microsoft.com

If I understand your question correctly:

Dim fd As FileDialog
Dim firstdoc As String
Dim basedoc As Document
Dim comparedocument As String
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.Title = "Select the Document that you want compared with the next
document that you will select."
.InitialFileName = ""
If .Show = -1 Then
firstdoc = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set basedoc = Documents.Open(firstdoc)
Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
.AllowMultiSelect = False
.Title = "Select the Document that you want to compare with " & firstdoc
.InitialFileName = ""
If .Show = -1 Then
comparedocument = .SelectedItems(1)
Else
Exit Sub
End If
End With
Set fd = Nothing
basedoc.Compare comparedocument


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP, originally posted via msnews.microsoft.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top