Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-11-2019, 08:07 AM
min257 min257 is offline Running Macro in Multiple word files Windows 8 Running Macro in Multiple word files Office 2016
Novice
Running Macro in Multiple word files
 
Join Date: Feb 2019
Posts: 2
min257 is on a distinguished road
Smile Running Macro in Multiple word files

Hello Administrator,


I've no knowledge in writing codes or running macro. Therefore, I'm seeking your help (I would really appreciate it).

I've like around 300 word files in a specific folder, that I need to add "Confidential - Not for distribution" in a footnote (currently there is nothing in the footer). Can you please help me create the macro for this? I would appreciate if you can use above text in your eg.

Once I run the macro, All files will have above note in footer? Thank you for your help and time!
Reply With Quote
  #2  
Old 02-11-2019, 08:21 AM
gmayor's Avatar
gmayor gmayor is offline Running Macro in Multiple word files Windows 10 Running Macro in Multiple word files Office 2016
Expert
 
Join Date: Aug 2014
Posts: 3,219
gmayor is a glorious beacon of lightgmayor is a glorious beacon of lightgmayor is a glorious beacon of lightgmayor is a glorious beacon of lightgmayor is a glorious beacon of lightgmayor is a glorious beacon of light
Default

You could use http://www.gmayor.com/document_batch_processes.htm to handle the documents and run the following as a custom process:


Code:
Function AddFooter(oDoc As Document) As Boolean
    On Error GoTo err_Handler
    Dim oSection As Section
    Dim oFooter As HeaderFooter
    For Each oSection In oDoc.Sections
        For Each oFooter In oSection.Footers
            If oFooter.Exists Then
                oFooter.Range.Text = "Confidential - Not for distribution"
            End If
        Next oFooter
    Next oSection
    AddFooter = True
lbl_Exit:
    Exit Function
err_Handler:
    AddFooter = False
    Resume lbl_Exit
End Function
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 02-11-2019, 09:01 AM
min257 min257 is offline Running Macro in Multiple word files Windows 8 Running Macro in Multiple word files Office 2016
Novice
Running Macro in Multiple word files
 
Join Date: Feb 2019
Posts: 2
min257 is on a distinguished road
Default

When I run the above the code it says "variable not defined"
Reply With Quote
  #4  
Old 02-11-2019, 09:54 PM
gmayor's Avatar
gmayor gmayor is offline Running Macro in Multiple word files Windows 10 Running Macro in Multiple word files Office 2016
Expert
 
Join Date: Aug 2014
Posts: 3,219
gmayor is a glorious beacon of lightgmayor is a glorious beacon of lightgmayor is a glorious beacon of lightgmayor is a glorious beacon of lightgmayor is a glorious beacon of lightgmayor is a glorious beacon of light
Default

Did you run it from the batch processor?
It works fine when run from there. Open a document and run it on that document using the following macro


Code:
Sub Macro1()
AddFooter ActiveDocument
End Sub
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Running Macro in Multiple word files Run a macro on multiple docx. files Peter Carter Word VBA 23 10-23-2019 10:04 PM
Macro for multiple RTF files papapaleo Word VBA 1 07-28-2017 04:56 AM
Running Macro in Multiple word files Macro for Combining Multiple Word Files Together Into One Document rsrasc Word VBA 2 10-31-2014 07:58 AM
Word 2010 running multiple instances JBE Word 0 09-28-2012 06:00 PM
Running Macro in Multiple word files looking for macro for multiple files bolk Word 3 05-03-2011 05:46 AM

Other Forums: Access Forums - Senior Forums

All times are GMT -7. The time now is 04:48 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2020, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft