Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Stripping Formating from Header/Footers

Can anyone help me with stripping the formating code from a header or
footer? This seems like a daunting task with all the possible
options. Is there a way to evaluate the header or footer to just get
the text back? Any hints on accomplishing this would be helpful.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9,101
Default Stripping Formating from Header/Footers

There is no way of doing this except the old fashion way. Remove the string
at the beginning of the text that begoin with an aphersand

Sub remove_format()
MyString = ActiveSheet.PageSetup.LeftHeader

While Left(MyString, 1) = "&"
MyString = Mid(MyString, 2)
If IsNumeric(Left(MyString, 1)) Then
'code is a number indicating font size
'remove number
Do While (IsNumeric(Left(MyString, 1)))
MyString = Mid(MyString, 2)
Loop
Else
If Left(MyString, 1) = "P+" Or _
Left(MyString, 1) = "P-" Then
'code is a Page Number
MyString = Mid(MyString, 3)
'remove number
Do While (IsNumeric(Left(MyString, 1)))
MyString = Mid(MyString, 2)
Loop
Else
'test if &&, then leave one &
'indicates a real & character
If Left(MyString, 1) < "&" Then
'code is only a single letter
'remove single letter
MyString = Mid(MyString, 2)
End If
End If
End If
Loop
End Sub


"CG" wrote:

Can anyone help me with stripping the formating code from a header or
footer? This seems like a daunting task with all the possible
options. Is there a way to evaluate the header or footer to just get
the text back? Any hints on accomplishing this would be helpful.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default Stripping Formating from Header/Footers

On Feb 15, 11:27 am, Joel wrote:
There is no way of doing this except the old fashion way. Remove the string
at the beginning of the text that begoin with an aphersand

Sub remove_format()
MyString = ActiveSheet.PageSetup.LeftHeader

While Left(MyString, 1) = "&"
MyString = Mid(MyString, 2)
If IsNumeric(Left(MyString, 1)) Then
'code is a number indicating font size
'remove number
Do While (IsNumeric(Left(MyString, 1)))
MyString = Mid(MyString, 2)
Loop
Else
If Left(MyString, 1) = "P+" Or _
Left(MyString, 1) = "P-" Then
'code is a Page Number
MyString = Mid(MyString, 3)
'remove number
Do While (IsNumeric(Left(MyString, 1)))
MyString = Mid(MyString, 2)
Loop
Else
'test if &&, then leave one &
'indicates a real & character
If Left(MyString, 1) < "&" Then
'code is only a single letter
'remove single letter
MyString = Mid(MyString, 2)
End If
End If
End If
Loop
End Sub

"CG" wrote:
Can anyone help me with stripping the formating code from a header or
footer? This seems like a daunting task with all the possible
options. Is there a way to evaluate the header or footer to just get
the text back? Any hints on accomplishing this would be helpful.


Joel,

That is what I thought. Your code is a good start. My concern is
this will only work if all the formating code is at the front of the
string. What if it is something very complex like:

"&D&Z&F
&"Arial,Bold"&12&UCustom Header&"Arial,Regular"&10&U
&F&A"

I am sure it is possible however for me to write the code it would end
up being very long and I doubt I would ever work through the logic. I
was hoping someone had done it.
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Header/Footers mikal77 Excel Worksheet Functions 2 June 16th 07 06:51 AM
Header and Footers Jules Excel Discussion (Misc queries) 4 July 7th 05 06:36 PM
Stripping time in Pivot Table Column Header T1 Red Alarm Excel Worksheet Functions 3 May 18th 05 12:09 AM
Repeating header/footers for excel sweetd Excel Worksheet Functions 3 December 17th 04 10:29 AM
Header and footers Lloyd Excel Programming 1 May 14th 04 12:20 PM


All times are GMT +1. The time now is 12:31 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"