I am using range.find.execute(sFindWord) in Word 2007 documents
and get error 4605 "This command is not available." I go
through a loop doing the find on 38 documents. It works fine
on all but three of the documents. They must not be protected,
because my program can open them without userid & password.
(When I have searched on Google for information on this error,
some say the problem is that the document is protected.) One
thing the documents which get the error have in common is that
they have embedded attachments - email messages and Word documents.
When I click on the attachment, I am taken to the top of the document
I am in. On the other hand, I can open such attachments in
one of the other documents.
Is there a way to open and do search in those documents?
Code:Dim WordApp As New Word.Application Dim docOpenedDocument As Microsoft.Office.Interop.Word.Document Dim wrdRange As Word.Range Dim iWordParagraph As Integer WordApp.Visible = False docOpenedDocument = WordApp.Documents.Open(ChangeToSharedPath(gsDatabaseNames(iThisDatabase)), _ objMissing, True) lblProgress.Text = "Searching: " & StrConv(gsDatabaseTypesFound(iThisDatabase), VbStrConv.ProperCase) _ & " Database (" & iNumDatabasesSearched.ToString _ & " of " & iNumDatabasesSearching.ToString & ") " & _ Path.GetFileNameWithoutExtension(gsDatabaseNames(iThisDatabase)) frmGridDisplay.lblSearchProgressGridForm.Text = lblProgress.Text Application.DoEvents() iSearchHit = 0 For iWordParagraph = 1 To docOpenedDocument.Paragraphs.Count If gbExitingGridForm Then 'MessageBox.Show("Grid form closed unexpectedly - ending search", "Ending Search") Exit Sub End If wrdRange = docOpenedDocument.Paragraphs(iWordParagraph).Range wrdRange.Find.ClearFormatting() If Not bUsingAdvancedSearch Then Error here -> If wrdRange.Find.Execute(sSearchPhrase.ToString) Then iSearchHit = 1 Exit For End If Else




Reply With Quote
