I simply do NOT believe you need "something like this for every single individual document?"
There is an inconsistency here.
Bookmark names are identical in each document. They are simply valued differently for each document. Those values come from the userform.
A call to a process will only take a parameter value one time. That is, it takes a value and does what it does...and then stops. For example:
Code:
Sub YaddaYadda()
Dim file
Dim path As String
path = "C:\ZZZ\Bookmarks\"
file = Dir(path & "*.doc")
Do While file <> ""
Documents.Open Filename:=path & file
[COLOR=red]' the above is now the ActiveDocument[/color red]
With ActiveDocument
.Bookmarks("here").Range.Text _
= txtWhatever.Text
.Save
.Close
End With
file = Dir()
Loop
End Sub
The code above will -
as I have already stated:
1. open EACH .doc file in c:\zzz\bookmarks
2. puts the text of a userform textbox - txtWhatever - in the bookmark "here".
This assumes each file HAS such a bookmark! This can be tested for (and probably should be!) of course.
3. saves the file
4. closes the file
5. opens the next file and repeats 1 to 4 until all .doc files are processed. This happens whether it is 20 files, 100 files, 246 files, or 800 files. The number of files is irrelevant (aside from possible memory hogging...)
If you are trying to state that you are processing 246 files in ONE process, and using different values for different files...then, hmmmm:
1. HOW are you determining which files gets which value?
2. More importantly, HOW are you
changing the value of the textbox on the userform? You can not do that while there are other processes actually executing.
I agree with strongm, this absolutely, positively, can be stream-lined to a tiny fraction of whatever code you have now.
"A little piece of heaven
without that awkward dying part."
advertisment for Reese's Peanut Butter Cups (a chocolate/peanut butter confection)
Gerry