Print portion of file path and tab name as footer automatically on ss

JSH720

Board Regular
Joined
Oct 9, 2009
Messages
107
Office Version
  1. 365
Platform
  1. Windows
I need to do two things, on ss open, ask if you want to print the filename ( see below) if yes, then
2. Print the file name and the last two folders going left plus the tab name oas footer in spreadsheet. for esxample if the path is x: jsh\nw\ HOUSTON\AREAS.XLS,then the filename that would print aws a footer (if you selected yes on the box on opening the spreadsheet): nw\ HOUSTON\AREAS.XLS. along with the tab nme : tab: tab name . It needs to go on the left footer and be Calib ri 9 pt font. In the right will be the date and time last updated and saved.

Thanks!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Try this code, which sets the left footer if the reply is Yes and clears it if the reply is No.

ThisWorkbook module:
Code:
Private Sub Workbook_Open()
    Set_Left_Footer MsgBox("Do you want to print the partial file path and name in the left footer?", vbYesNo)    
End Sub
Standard module:
Code:
Public Sub Set_Left_Footer(reply As Long)
    
    Dim p As Long
    Dim LeftFooterText As String
    
    If reply = vbYes Then
        p = InStrRev(ThisWorkbook.FullName, "\")
        p = InStrRev(ThisWorkbook.FullName, "\", p - 1)
        p = InStrRev(ThisWorkbook.FullName, "\", p - 1)
        LeftFooterText = Mid(ThisWorkbook.FullName, p + 1) & " tab: " & ActiveSheet.Name
        ActiveSheet.PageSetup.LeftFooter = "&""Calibri""&9 " & LeftFooterText
    Else
        ActiveSheet.PageSetup.LeftFooter = ""
    End If
    
End Sub
 
Upvote 0

Forum statistics

Threads
1,214,908
Messages
6,122,187
Members
449,071
Latest member
cdnMech

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top