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