Thursday, May 23, 2013   
  Search   
 

Office 2010 - Launch Event

Register  Login  
Forums  
     Minimize  

MeraWindows Forums - Get your Computer Problems Fixed

This is a site run by the community - for the community. At the site, we share and contribute our computer learnings with each other. We discuss about Windows, Office, Mobile, Gaming and other computer related topics. At our forums you can post your queries and our very helpful community members will respond quickly to your queries. We organize lots of competitions from time to time and award prizes to the winners.
You will need to register at the site before posting in forums. It's absolutely free. After registering, you can get all the benefits available to our registered members, you can access our Downloads section, you can participate in contests, etc. You can post in forums in English as well as in Hindi, in fact we encourage you to use Hindi in your posts. If you have any problem with registration or login, please contact us.

     
  
HomeHomeMicrosoft Offic...Microsoft Offic...Microsoft ExcelMicrosoft ExcelCode to change Footer in all workbooks residing in a folderCode to change Footer in all workbooks residing in a folder
Previous
 
Next
New Post
11/16/2011 12:45 PM
 
Hi,

I am using the following code to change the footer in all worksheets of a workbook. How do i modify the code to change the footer in all workbooks stored in a folder?

Code:

Sub Footer()

Static wbSrcPath As String: wbSrcPath = Application.GetOpenFilename("Excel Files, *.xls*")
If wbSrcPath = "False" Then Exit Sub

Application.ScreenUpdating = False
Static wbSrc As Workbook: Set wbSrc = Workbooks.Open(wbSrcPath)

Dim ws As Worksheet
Application.ScreenUpdating = False
For Each ws In wbSrc.Worksheets

With ws.PageSetup
.CenterFooter = "&""Calibri,Regular""&10Company Name"
End With
Next ws
Set ws = Nothing
ActiveWindow.View = xlNormalView
wbSrc.Save
wbSrc.Close False
Application.StatusBar = False
End Sub
 
New Post
11/17/2011 5:23 AM
 
Hi,

Try this

1. Assume all your workbooks in which you want to change the footer are in a folder named Data saved on your desktop.  This folder should only have those Excel files and nothing else

2. Open a blank workbook and enter the following code in a module

Sub ListFiles()
Z = 1
F = Dir("C:\Users\Ashish\Desktop\Data\*.XL*")
Do While Len(F) > 0
    Range("A" & Z).Formula = F
    F = Dir()
    Z = Z + 1
Loop
End Sub

When this code is run, it will list down all XL* files in the Data folder from cell A1 onwards (of the blank workbook which you just opened in step 2).

3. In the same open workbook, enter the following code in another module

Sub open_file()
Application.ScreenUpdating = False
Dim ws As Worksheet
For n = 1 To Range("A1").currentregion.rows.count
    Workbooks.Open Filename:="C:\Users\Ashish\Desktop\Data\" & Range("A" & n)
    For Each ws In ActiveWorkbook.Worksheets
        With ws.PageSetup
        .CenterFooter = "&""Calibri,Regular""&10Company Name"
    End With
    Next ws
    Set ws = Nothing
    ActiveWindow.View = xlNormalView
    ActiveWorkbook.Save
    ActiveWorkbook.Close False
    Application.StatusBar = False
Next n
Application.ScreenUpdating = true
End Sub

When you run this code, it will apply your desired footer to all worksheets of all workbooks in the Data folder

Hope this helps.

Do let me know how this works for you.

For Microsoft Excel trainings in India, please visit http://www.ashishmathur.com/corporate-interventions/

Regards,

Ashish Mathur - View Ashish Mathur's profile on LinkedIn
Microsoft Excel MVP
Website
Blog
 
New Post
11/21/2011 1:31 PM
 
thanks it works gr8!!!!

Is it possible to make this as an add-in? Perhaps C:\Users\<$username>\Desktop\ - should be made as a default folder i guess, if the add-in is made available to multiple users, not sure though...

Thanks again!!!
 
New Post
11/21/2011 1:53 PM
 
You are welcome.  Glad to help.  For creating an add-in from this, please Google the process.

For Microsoft Excel trainings in India, please visit http://www.ashishmathur.com/corporate-interventions/

Regards,

Ashish Mathur - View Ashish Mathur's profile on LinkedIn
Microsoft Excel MVP
Website
Blog
 
Previous
 
Next
HomeHomeMicrosoft Offic...Microsoft Offic...Microsoft ExcelMicrosoft ExcelCode to change Footer in all workbooks residing in a folderCode to change Footer in all workbooks residing in a folder


   User Log In Minimize  


Register
Forgot Password ?

     
  
   Follow Us Minimize  
     
  
     Minimize