Switching Windows Error

C

C_P

Hello,

Currently, I am working on a document that analyzes other documents.
Basically, the user clicks on a button and a dialog box opens up to
browse to a file and the analyzation begins.
It can bring up the dialog box correctly and minimize the current
window of the original document, but when I try to bring the document
to be analyzed into focus, it gives the error:

'Runtime error 5941':
The requested member of the collection does not exist.

Here is the code:
With Dialogs(wdDialogFileOpen)
.Display
DocToAnalyze = WordBasic.FilenameInfo$(.Name, 2)
End With
'On Error GoTo ErrorHandler

'Windows(analyzedoc).WindowState = wdWindowStateMinimize
Windows(DocToAnalyze).Activate

I have commented everything out around the last line and targeted it as
the source of the error, but I am not for sure why. I have tried
putting in other documents open such as "Document4.doc" and "Document4"
but to no avail.

Thank you for any help.
 
D

Doug Robbins - Word MVP

Use:

Dim mydoc as document
Dim DocToAnalyze as String

With Dialogs(wdDialogFileOpen)
.Display
DocToAnalyze = WordBasic.FilenameInfo$(.Name, 2)
End With
Set mydoc = Documents.Open(DocToAnalyze
mydoc.Activate


--
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
 

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