We have about 1500 documents that we are adding a watermark to. We have recorded a macro to add the watermark to the document. We open the document, run the macro, save, and close the document. This is getting very boring. Is there a way to run the macro on all documents or multiple documents at the same time?
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
-
Running a macro on multiple docs at the same time (Word 97 SR2)
Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Running a macro on multiple docs at the same time (Word 97 SR2)
- This topic has 17 replies, 7 voices, and was last updated 23 years, 7 months ago.
Viewing 0 reply threadsAuthorReplies-
WSGary Frieder
AskWoody LoungerOctober 16, 2001 at 4:48 am #546933Here’s a stripped-down means to do this:
Public Sub InsertWatermarksInMultipleDocs() Dim sPath As String Dim i As Long sPath = InputBox("Type Path for Folder to be Searched") With Application.FileSearch .NewSearch .LookIn = sPath .FileType = msoFileTypeWordDocuments If .Execute > 0 Then For i = 1 To .FoundFiles.Count Documents.Open (.FoundFiles(i)) 'Your code to insert watermarks here '################################# ActiveDocument.Close (wdSaveChanges) Next 'i Else: MsgBox prompt:="Folder not found. Check path and try again." Exit Sub End If End With End Sub
Gary
-
erh3
AskWoody Lounger -
WSREllrod
AskWoody Lounger -
WSChris Green
AskWoody Lounger -
erh3
AskWoody Lounger -
WSGary Frieder
AskWoody LoungerOctober 17, 2001 at 8:03 am #547182The following is a very quick and dirty amendment to your code so that it will only run if there is no graphic object (Shape) in the header/footer:
If ActiveWindow.View.SplitSpecial wdPaneNone Then ActiveWindow.Panes(2).Close End If If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _ ActivePane.View.Type = wdOutlineView Or ActiveWindow.ActivePane.View.Type _ = wdMasterView Then ActiveWindow.ActivePane.View.Type = wdPageView End If ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader If Selection.HeaderFooter.IsHeader = True Then ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter Else ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader End If Dim rngTemp As Range Selection.WholeStory Set rngTemp = Selection.Range On Error Resume Next If rngTemp.ShapeRange.Count = 0 Then Selection.HeaderFooter.Shapes.AddTextbox(msoTextOrientationHorizontal, _ 72#, 676.8, 468#, 115.2).Select Selection.ShapeRange.TextFrame.TextRange.Select Selection.Collapse Selection.ShapeRange.Fill.Visible = msoFalse Selection.ShapeRange.Line.Visible = msoFalse Selection.HeaderFooter.Shapes.AddTextEffect(msoTextEffect2, "History", _ "Times New Roman", 96#, msoFalse, msoFalse, 161.7, 401.15).Select Selection.ShapeRange.Fill.ForeColor.RGB = RGB(192, 192, 192) Selection.ShapeRange.Fill.Visible = msoTrue Selection.ShapeRange.Fill.Solid Selection.ShapeRange.Select Selection.ShapeRange.IncrementLeft 11.1 Selection.ShapeRange.IncrementTop -98.75 End If Set rngTemp = Nothing ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
Gary
-
WSKathleen
AskWoody Lounger -
WSGary Frieder
AskWoody Lounger -
WSKathleen
AskWoody LoungerOctober 17, 2001 at 5:36 pm #547276OK, i’m on a network, i typed in the entire path and the macro had a good time looking for documents. it listed a bunch as it went thru them, but none were known to me nor the ones in the path i gave it.
long prelude, question-is it because i’m on a network and there are like several shared directories?
-
WSGary Frieder
AskWoody LoungerOctober 18, 2001 at 4:29 am #547372Hi Kathleen,
It’s really hard to tell what’s going on in that case.
When you say it listed the docs as it went through them, what do you mean? – do you mean the name of the document displays on the status bar, or what exactly?I’m not much of a network whiz so am not sure what effect shared directories would have.
Try the following: try having the macro search for files in a directory that’s on your local drive.
If it works OK to find files on your local drive, but not on a networked drive, then that would point to a network issue.Hope that helps,
Gary -
WSKathleen
AskWoody LoungerOctober 18, 2001 at 1:27 pm #547433OK, cool. the status bar says ‘opening’ then lists the files its going thru; on the network directory it listed main.htm and panasonic.html. no clue what they are. i tried it on the c drive and (after deleting one line of duplicate rngTemp) it whipped thru the files stamping history and a box! really cool! i’ll fiddle to see what else i can do in place of the graphic! since most docs are in the network, i’d really like ideas for using on that!
thanks for the help!
-
erh3
AskWoody LoungerOctober 18, 2001 at 1:36 pm #547436I tried the macro on the network too. It still put a graphic on the documents that already contained the watermark. I am not sure why it puts the gray box on the docs. I am going to redo the watermark part, since I may have made a mistake when I recorded it. Why would it still put the watermark on docs that already contain it? I will be using this on the network though, if that makes a difference.
-
WSjscher2000
AskWoody LoungerOctober 19, 2001 at 5:35 am #547628I can’t get the ShapeRange property of the Selection object to work either.
The following property gives an accurate count, but you need to find a way to know where you are (header or footer and which one):
Selection.Range.Sections(1).Headers(wdHeaderFooterFirstPage).Shapes.Count
Too late tonight to figure it out.
-
erh3
AskWoody Lounger -
erh3
AskWoody Lounger -
WSGary Frieder
AskWoody LoungerOctober 25, 2001 at 6:01 am #548507Hi again,
The statement towards the beginning of the procedure:
Documents.Open(.FoundFiles(i))
opens the document, and the statement towards the end:
ActiveDocument.Close (wdSaveChanges)
should be serving to close it.
That’s usually a reliable enough way to specify the correct document you want the code to be working on, but if it’s not working, a couple of other means can be used:Documents.Close(.FoundFiles(i))
should work more reliably since it refers to the document by index (caveat that I haven’t tested it with your procedure).
An even more reliable method is to create an object variable and set it to equal the document as it opens:
Dim objDoc As Document
Set objDoc = Documents.Open (.FoundFiles(i))and then later one you use:
objDoc.Close (wdSaveChanges)
Set objDoc = NothingWith regard to the other post about the watermark getting inserted in documents that already have it – the code I suggested relied on getting a count of existing shapes in the header or footer.
This isn’t really reliable – as Jeff pointed out in his note – as it’s hard to get a count of shapes, particularly if the code isn’t specific as to whether you’re in the header or footer.
So the code would need to be more specific that way.Probably a more reliable way to test for the existence of a watermark in the document, would be to have the insert watermark code finish by adding either a bookmark or custom document property to the document (for example adding a boolean (Yes or No) “HasWatermark” custom document property and setting its value to Yes.
Then, the insert watermark procedure would first test for the existence of this custom document property, and whether its property was set to Yes.
There’s been some code posted here recently for adding custom doc props as well as testing whether one already exists – a search on this forum (or possibly the VBA forum) should turn up more info.
Gary
-
-
-
-
-
WSsolomod
AskWoody LoungerNovember 2, 2001 at 7:03 am #549780Hi Gary
Just like to say a big thank you for putting up the batch operation macro. I’ve never understood public macros and furthermore I have a huge number of docs where the paper source box has to be changed to Auto. I have just inserted my own box-change macro and whizzed through nearly half of them.
Many thanks.
David Solomon
Viewing 0 reply threads -

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
Very Quarrelsome Taskbar!
by
CWBillow
1 hour, 51 minutes ago -
Move OneNote Notebook OFF OneDrive and make it local
by
CWBillow
4 hours, 35 minutes ago -
Microsoft 365 to block file access via legacy auth protocols by default
by
Alex5723
5 hours, 54 minutes ago -
Is your battery draining?
by
Susan Bradley
1 hour, 22 minutes ago -
The 16-billion-record data breach that no one’s ever heard of
by
Alex5723
7 hours, 51 minutes ago -
Weasel Words Rule Too Many Data Breach Notifications
by
Nibbled To Death By Ducks
8 hours, 27 minutes ago -
Windows Command Prompt and Powershell will not open as Administrator
by
Gordski
11 hours, 42 minutes ago -
Intel Management Engine (Intel ME) Security Issue
by
PL1
2 hours, 25 minutes ago -
Old Geek Forced to Update. Buy a Win 11 PC? Yikes! How do I cope?
by
RonE22
4 hours, 56 minutes ago -
National scam day
by
Susan Bradley
7 hours, 52 minutes ago -
macOS Tahoe 26 the end of the road for Intel Macs, OCLP, Hackintosh
by
Alex5723
5 hours, 7 minutes ago -
Cyberattack on some Washington Post journalists’ email accounts
by
Bob99
1 day, 9 hours ago -
Tools to support internet discussions
by
Kathy Stevens
1 day, 16 hours ago -
How get Group Policy to allow specific Driver to download?
by
Tex265
1 day ago -
AI is good sometimes
by
Susan Bradley
1 day, 16 hours ago -
Mozilla quietly tests Perplexity AI as a New Firefox Search Option
by
Alex5723
1 day, 6 hours ago -
Perplexity Pro free for 12 mos for Samsung Galaxy phones
by
Patricia Grace
2 days, 17 hours ago -
June KB5060842 update broke DHCP server service
by
Alex5723
2 days, 15 hours ago -
AMD Ryzen™ Chipset Driver Release Notes 7.06.02.123
by
Alex5723
2 days, 19 hours ago -
Excessive security alerts
by
WSSebastian42
1 day, 10 hours ago -
* CrystalDiskMark may shorten SSD/USB Memory life
by
Alex5723
3 days, 5 hours ago -
Ben’s excellent adventure with Linux
by
Ben Myers
2 hours, 17 minutes ago -
Seconds are back in Windows 10!
by
Susan Bradley
2 days, 16 hours ago -
WebBrowserPassView — Take inventory of your stored passwords
by
Deanna McElveen
1 day, 9 hours ago -
OS news from WWDC 2025
by
Will Fastie
19 hours, 54 minutes ago -
Need help with graphics…
by
WSBatBytes
2 days ago -
AMD : Out of Bounds (OOB) read vulnerability in TPM 2.0 CVE-2025-2884
by
Alex5723
3 days, 20 hours ago -
Totally remove or disable BitLocker
by
CWBillow
2 days, 19 hours ago -
Windows 10 gets 6 years of ESU?
by
n0ads
2 days, 22 hours ago -
Apple, Google stores still offer China-based VPNs, report says
by
Nibbled To Death By Ducks
4 days, 7 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.