Open docs in minimized state?

D

danaho

I have about 50 Word files that must be updated regularly. Using
Word2000, I wrote a procedure in a file called tools.doc that prompts
the user for a folder, oldText and newText with a userform. The
procedure then opens each .doc file in the folder, replaces oldText
with newText and then saves/closes it.

What I would like to do is: minimize Word when the procedure starts,
open each doc in the minimized state, replace, save and close (all in
the minimized state.

What I currently have minimizes the application (tools.doc), but each
doc in the user-supplied folder is opened with the window in the normal
state, then it is minimized, processed, saved and closed. Having the
50 files open in normal state then minimize is pretty annoying.

Here's the relevant code:
Code:
--------------------

' get current window state to restore at end and minimize
curWindowState = Application.WindowState
If Application.WindowState <> wdWindowStateMinimize Then
Application.WindowState = wdWindowStateMinimize
End If

<get collection of files in user-supplied folder>

Application.ScreenUpdating = False

For Each f1 In fc
If f1.Type = "Microsoft Word Document" Then
With Documents
.Open fqDocFile
.Application.WindowState = wdWindowStateMinimize
End With

<replace oldText with newText>

ActiveDocument.Close (wdSaveChanges)
End If
Next

Application.ScreenUpdating = True

Application.WindowState = curWindowState
--------------------

As I said, each document opens in the normal state first, then
minimizes. I'd like to just have each open already minimized.

Any ideas? Thanks!
 
J

JGM

Hi Danaho,

Instead of Minimizing the document, why not making it invisible?
I am not sure when Word introduced this parameter, but I think it was Word
2000:

Try:
.Open fqDocFile, Visible:=False

I use it often and it works like a charm!

Cheers!
 

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