I am using C# to automate Excel (using Excel = Microsoft.Office.Interop.Excel). Can anyone tell me how to detect if you are in a header or footer section of your excel document programmatically.

I need to write some text, but if the user is in header or footer then text must go to the header or footer not the current cell. Any thoughts?