0
Answer

Manipulating Word documents

Brosborough

Brosborough

19y
2.1k
1
I'm running into a problem with opening and then trying to close Word documents in VB.net. This code worked ok in VB6 but getting an error when trying to close the document once the word search is complete: For j% = 0 To UBound(strFileBuff) LstResults.ForeColor = Color.Red ProgressBar1.Value = ProgressBar1.Value + 1 strPath = strFileBuff(j%) commandSearch.Enabled = False Me.Text = "Searching " & strPath wd.Documents.Open(strPath) wd.ActiveDocument.Activate() myRange = wd.ActiveDocument.Content myRange.Find.Execute(FindText:=cmbWord.Text, _ Forward:=True) While myRange.Find.Found = True i% = i% + 1 myRange.Find.Execute(FindText:=cmbWord.Text) End While If i% > 0 Then LstResults.Items.Add(strPath) i% = 0 wd.ActiveDocument.Close() End If Next j% THE ERROR IS WITH WD.ACTIVEDOCUMENT.CLOSE() - I GET THE MESSAGE - "Close is ambiguous across inherited interfaces 'Word._Document' and 'Word.Document Events_Event'. Same thing if I try to use wd.close. ANY SUGGESTIONS?