|
-
Sep 23rd, 2011, 03:15 PM
#1
Thread Starter
Member
VB.Net 2010 find.execute in Word 2007 Gets Error 4605
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
-
May 28th, 2012, 08:42 AM
#2
New Member
Re: VB.Net 2010 find.execute in Word 2007 Gets Error 4605
i have the same problem in VB2008+Word2007. the Solution is reinstall word2007 after the visual stadio 2008 or 2010 installation.
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|