Hi John,
Thank you for replying!
In C#, the string ["&""Arial Unicode MS,Regular""Header Text"] will be thought invalid by the complier for so many quotation in this string. We can
use StringBuilder class to read this string and stringbuild class will transfer the string into one valid format which C# compiler prefers automatically.
I write the sample codes for you.
//Code begin
//the stringbuilder class is in the System.Text namespace
using System.Text;
...
try
{
Excel.Worksheet objWS;
StringBuilder str = new StringBuilder();
// the ["&""Arial Unicode MS,Regular""Header Text"] will be transferred into
// ["&\"Arial Unicode MS,Regular\"Header Text"] by stringBuilder internally
// which is valid in C#
str.Append(@"&""Arial Unicode MS,Regular""Header Text");
objWS = (Excel.Worksheet)this.ThisApplication.ActiveSheet;
objWS.PageSetup.LeftFooter = str.ToString();
}
catch(System.Exception ex)
{
MessageBox.Show(ex.Message);
}
//Code end
Furthermore, in your project, I'd suggest you can also use stringbuilder to create your footer and header string very easily with the Append
method.
In addition, in Visual Basic.Net and VBA, we can directly pass the ["&""Arial Unicode MS,Regular""Header Text"] string for the footer and header.
Please feel free to let me know if you have any further questions.
Does this answer your question? Thank you for using Microsoft NewsGroup!
Wei-Dong Xu
Microsoft Product Support Services
Get Secure! -
www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.