View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Andoni[_41_] Andoni[_41_] is offline
external usenet poster
 
Posts: 1
Default Automate adding code

This may look a primitive way, but it will work!


Sub TryThis()
Dim Filename As Variant
Dim X As Long
Dim Wkb As Workbook
Dim Sht As Object
'Gets the File name
Filename = Application.GetOpenFilename( _
FileFilter:="Excel Files (*.Xls),*.Xls", _
Title:="Chose your Excel File/s!", _
MultiSelect:=True)

Application.ScreenUpdating = False
'Exits if you cancel
If Not IsArray(Filename) Then
MsgBox "No File/s where selected"
Exit Sub
End If
For X = LBound(Filename) To UBound(Filename)
Set Wkb = Workbooks.Open(Filename:=Filename(X))
For Each Sht In ActiveWorkbook.Sheets
Sht.PageSetup.LeftHeader = ThisWorkbook.FullName
Next Sht
Wkb.Save
Wkb.Close
Next
End Su

--
Message posted from http://www.ExcelForum.com