You're going to need to explain better what you want it to do, exactly. Why do you need to update the file name and page number each time the file is saved? Do you expect these things to change very often? Also, updating the file name text before the file is saved doesn't make much sense, becuase if the name is changed it will not reflect that. It's wiser to do update the header when the file is opened, for example.
Thank you for the response.As you mentioned,i need the header and page number to be updated when the file is opened.I have lot of files which will be stored in a database.All files has its on naming convention and the file name shall be header of the file.So before i upload the file to the database,the header should be added.So i will be glad if the header is added automatically once i open the file in my machine.I can save it in same name and once it is uploaded to the database,nobody will change it.